aspx page
asp:UpdatePanel ID="formUpdatePanelProceedingDetails" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="divAddNew" runat="server" class="PopupAddButton">
<asp:LinkButton ID="lnkAddNew" runat="server" OnClick="lnkAddNew_Click" CausesValidation="false">
<i class="md-icon clndr_add_event material-icons hideforview" style="color: #fff; background: #7cb342;"></i>
</asp:LinkButton>
</div>
<div class="md-card uk-margin-medium-bottom">
<div class="md-card-content">
<div class="uk-overflow-container">
<asp:UpdatePanel ID="gridUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table class="uk-table" id="tblActSection">
<thead>
<tr>
<th>Date of Institution</th>
<th>Next Date of Hearing</th>
<th>Conducting Procutor or being handled by</th>
<th>Law Officer</th>
<th>Name Of Special Council</th>
<th>Handlign Since</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptProceedingDetails" runat="server">
<ItemTemplate>
<tr>
<td>
<%#DataBinder.Eval(Container, "DataItem.DtOfInstitution")%>
</td>
<td>
<%#DataBinder.Eval(Container, "DataItem.NextHearingDate")%>
</td>
<td>
<%#DataBinder.Eval(Container, "DataItem.ConductingOfficerType")%>
</td>
<td>
<%#DataBinder.Eval(Container, "DataItem.LawOfficerId")%>
</td>
<td>
<%#DataBinder.Eval(Container, "DataItem.NameSplCounsel")%>
</td>
<td>
<%#DataBinder.Eval(Container, "DataItem.HandlingSince")%>
</td>
<td>
<asp:UpdatePanel ID="editUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton runat="server" ID="lnkEdit" CausesValidation="false" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.Guid")%>'><i class="fa fa-pencil-square-o" aria-hidden="true" onclick="lnkEdit_Click"></i></asp:LinkButton>
<asp:LinkButton runat="server" ID="lnkView" CausesValidation="false" Visible="false" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.Guid")%>' onclick='lnkView_Click'><i class="fa fa-eye" aria-hidden="true"></i></asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkEdit" />
<asp:AsyncPostBackTrigger ControlID="lnkView" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel ID="deleteUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton runat="server" ID="lnkDelete" CausesValidation="false" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.Guid")%>'><i class="fa fa-trash" aria-hidden="true"></i></asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkDelete" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<%--<asp:UpdatePanel ID="formUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>--%>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="modal fade" id="modal_Proceeding" runat="server" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-keyboard="false" data-backdrop="static" style="display: none;z-index:9999">
<div class="modal-dialog" role="document" >
<div class="modal-content">
<asp:UpdatePanel ID="UpdatePanelProceedingFormModel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-header">
<%-- <button type="button" class="close" aria-label="Close" onclick='HideModalsUploadDocumentUsingSession("<%=modal_UploadDocumentUsingSession.ClientID%>")'>
<span aria-hidden="true">×</span>
</button>--%>
<h4 class="modal-title"> <asp:Label ID="lblHeader" runat="server" Text="Proceedings"></asp:Label></h4>
<button type="button" class="btn-close btn-outline-dark" data-bs-dismiss="modal" onclick='HideProceedingModals("<%=modal_Proceeding.ClientID%>")' aria-label="Close"></button>
</div>
<div class="modal-body">
<asp:HiddenField ID="hdnGuid" runat="server" />
<asp:HiddenField ID="hdnGuidDataId" runat="server" />
<div class="uk-grid">
<div class="uk-width-1-1">
<div class="lbl-control uk-width-1-3">
<asp:Label runat="server" Text="Date of Institution"></asp:Label><span class="starcolor"> </span>
</div>
<asp:TextBox ID="txtDateOfInstitution" runat="server" class="uk-width-1-2 form-control-sm datepickerIcon" MaxLength="16" onclick="judgementOrderDate(this.id)"/>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1">
<div class="lbl-control uk-width-1-3">
<asp:Label runat="server" Text="Next Date of Hearing"></asp:Label><span class="starcolor"> </span>
</div>
<asp:TextBox ID="txtNextDateOfHearing" runat="server" class="uk-width-1-2 form-control-sm datepickerIcon" MaxLength="16" onclick="judgementOrderDate(this.id)"/>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1">
<asp:Label runat="server" class="lbl-control uk-width-1-3" ClientIDMode="Static" Text="Conducting Prosecutor or being handled by"></asp:Label>
<asp:DropDownList ID="ddlConductingProsecutor" runat="server" CssClass="uk-width-1-2">
</asp:DropDownList>
<%--<asp:RequiredFieldValidator ID="rfvSecrecyLevel" runat="server" ControlToValidate="ddlSecrecyLevel" ErrorMessage="Value is required" ValidationGroup="UCUploadDocumentUsingSession" CssClass="Validators-uk-width-1-2" SetFocusOnError="true" Display="Dynamic" InitialValue="0"></asp:RequiredFieldValidator>--%>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1">
<asp:Label runat="server" class="lbl-control uk-width-1-3" ClientIDMode="Static" Text="Law Officer"></asp:Label>
<asp:DropDownList ID="ddlLawOfficer" runat="server" CssClass="uk-width-1-2">
</asp:DropDownList>
<%--<asp:RequiredFieldValidator ID="rfvSecrecyLevel" runat="server" ControlToValidate="ddlSecrecyLevel" ErrorMessage="Value is required" ValidationGroup="UCUploadDocumentUsingSession" CssClass="Validators-uk-width-1-2" SetFocusOnError="true" Display="Dynamic" InitialValue="0"></asp:RequiredFieldValidator>--%>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1">
<div class="lbl-control uk-width-1-3">
<asp:Label runat="server" Text="Name of Special Counsel"></asp:Label><span class="starcolor"> </span>
</div>
<asp:TextBox ID="txtNameOfSpecialCounsel" runat="server" class="uk-width-1-2 form-control" MaxLength="16" />
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1">
<div class="lbl-control uk-width-1-3">
<asp:Label runat="server" Text="Handling Since"></asp:Label><span class="starcolor"> </span>
</div>
<asp:TextBox ID="txtHandlingSince" runat="server" class="uk-width-1-2 form-control-sm datepickerIcon" MaxLength="16" onclick="judgementOrderDate(this.id)"/>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="md-btn md-btn-warning" OnClick="btnAdd_Click" CausesValidation="true" ValidationGroup="UCUploadDocumentUsingSession" UseSubmitBehavior="false" Style="color: #fff !important; background: #7cb342 !important;" />
<asp:Button ID="btnClear" runat="server" Text="Clear" CssClass="md-btn" CausesValidation="false"></asp:Button>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
<div class="modal fade" runat="server" id="ManageStatementDelete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;z-index:9999" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
Confirmation
</div>
<div class="modal-body">
<asp:HiddenField runat="server" ID="hdnGuidProceedingId" ClientIDMode="Static" Visible="false"></asp:HiddenField>
<div id="divManageStatementDelete" >
Are you sure you want to delete?
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btnDelete" runat="server" CssClass="btn btn-primary" OnClick="btnDelete_Click" OnClientClick="javascript:CloseManageStatementDeleteModal(this.id);" UseSubmitBehavior="false" CausesValidation="false" Text="Yes" ></asp:Button>
<asp:Button ID="btnCancel" runat="server" CssClass="btn" OnClientClick="javascript:CloseManageStatementDeleteModal(this.id);" Text="No"></asp:Button>
</div>
</div>
</div>
</div>
<script>
function OpenManageStatementDeleteModal(modalId) {
//var div = document.getElementById('divManageStatementDelete');
//div.style.display = 'block';
$("#" + modalId).modal("show");
}
function CloseManageStatementDeleteModal(popupId) {
//var modalId = $("[id$=" + popupId + "]").attr("id");
//$("#" + modalId).modal("hide");
var modalId = $('#' + popupId).parents(':eq(3)');
$(modalId).modal('hide');
}
</script>
----------------------
aspx.cs page (For Adding to Repeater)
public List<CourtApplicationProceedingsDTO> GetAllCourtApplicationProceedingsData()
{
List<CourtApplicationProceedingsDTO> courtApplicationProceedingsList = new List<CourtApplicationProceedingsDTO>();
if (!string.IsNullOrEmpty(Convert.ToString(Session["CourtApplicationProceedings"])))
{
courtApplicationProceedingsList = (List<CourtApplicationProceedingsDTO>)Session["CourtApplicationProceedings"];
}
return courtApplicationProceedingsList;
}
public void LoadCourtApplicationProceedings()
{
var courtApplicationProceedingsDto = GetAllCourtApplicationProceedingsData();
rptProceedingDetails.DataSource = courtApplicationProceedingsDto.Where(t => t.IsActive == true).ToList();
rptProceedingDetails.DataBind();
gridUpdatePanel.Update();
}
public void GetAllActSectionDetailsByReferenceIdAndReferenceType()
{
List<ActSectionDetailsDTO> actSectionDetailsList = new List<ActSectionDetailsDTO>();
using (var client = ServiceClient<IActSectionDetailsManager>.Create(ObjectConstants.ActSectionDetailsManager))
{
actSectionDetailsList = client.Instance.GetAllActSectionDetailsByReferenceIdAndReferenceType(ReferenceId, ReferenceType);
}
if (actSectionDetailsList.Count > 0)
{
actSectionDetailsList.ForEach(t => t.Guid = Guid.NewGuid().ToString());
Session["ActSectionDetails"] = actSectionDetailsList;
LoadCourtApplicationProceedings();
}
}
public void loadCourtApplicationProceedingsData(List<CourtApplicationProceedingsDTO> proceedingsList)
{
Session["CourtApplicationProceedings"] = proceedingsList;
LoadCourtApplicationProceedings();
}
protected void lnkAddNew_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(formUpdatePanelProceedingDetails, formUpdatePanelProceedingDetails.GetType(), Guid.NewGuid().ToString(), String.Format("OpenProceedingModals('" + modal_Proceeding.ClientID + "');"), true);
ClearControls();
hdnGuidDataId.Value = "";
//divFormControls.Visible = true;
formUpdatePanelProceedingDetails.Update();
}
protected void btnAdd_Click(object sender, EventArgs e)
{
if (true)
{
var courtApplicationProceedingDetailsDto = GetAllCourtApplicationProceedingsData();
List<CourtApplicationProceedingsDTO> dto = GetAllCourtApplicationProceedingsData();
int isExist = 0;
List<CourtApplicationProceedingsDTO> proceedingDetailsList = new List<CourtApplicationProceedingsDTO>();
if (true)//(hdnGuid.Value == "")
{
proceedingDetailsList.Add(new CourtApplicationProceedingsDTO
{
Guid = Guid.NewGuid().ToString(),
DtOfInstitution = Convert.ToDateTime(txtDateOfInstitution.Text),
NextHearingDate = Convert.ToDateTime(txtNextDateOfHearing.Text),
ConductingOfficerType = (string.IsNullOrEmpty(ddlConductingProsecutor.SelectedItem.Value) ? (Int32)(Int32)Convert.DBNull : Convert.ToInt32(ddlConductingProsecutor.SelectedItem.Value)),
LawOfficerId = (string.IsNullOrEmpty(ddlLawOfficer.SelectedItem.Value) ? (Int32?)null: Convert.ToInt32(ddlLawOfficer.SelectedItem.Value)),
NameSplCounsel = txtNameOfSpecialCounsel.Text,
HandlingSince = Convert.ToDateTime(txtHandlingSince.Text),
//OfficeID = CurrentUser.OfficeId,
IsActive = true
//CreatedBy = CurrentUser.UserId,
//CreatedDate = DateTime.Now,
//CreatedIPAddress = CurrentUser.IpAddress,
//UpdatedBy = CurrentUser.UserId,
//UpdatedDate = DateTime.Now,
//UpdatedIPAddress = CurrentUser.IpAddress,
});
}
else
{
int index = courtApplicationProceedingDetailsDto.FindIndex(m => m.Guid == hdnGuid.Value.ToString());
if (index >= 0)
{
courtApplicationProceedingDetailsDto[index] = new CourtApplicationProceedingsDTO
{
Guid = Guid.NewGuid().ToString(),
DtOfInstitution = Convert.ToDateTime(txtDateOfInstitution.Text),
NextHearingDate = Convert.ToDateTime(txtNextDateOfHearing.Text),
ConductingOfficerType = (Int32)(string.IsNullOrEmpty(ddlConductingProsecutor.SelectedItem.Value) ? Convert.DBNull : Convert.ToInt32(ddlConductingProsecutor.SelectedItem.Value)),
LawOfficerId = (Int32)(string.IsNullOrEmpty(ddlLawOfficer.SelectedItem.Value) ? Convert.DBNull : Convert.ToInt32(ddlLawOfficer.SelectedItem.Value)),
NameSplCounsel = txtNameOfSpecialCounsel.Text,
HandlingSince = Convert.ToDateTime(txtHandlingSince.Text),
//OfficeID = CurrentUser.OfficeId,
IsActive = true
//CreatedBy = CurrentUser.UserId,
//CreatedDate = DateTime.Now,
//CreatedIPAddress = CurrentUser.IpAddress,
//UpdatedBy = CurrentUser.UserId,
//UpdatedDate = DateTime.Now,
//UpdatedIPAddress = CurrentUser.IpAddress,
};
}
}
if (hdnGuidDataId.Value != "" && isExist == 0)
{
int index = courtApplicationProceedingDetailsDto.FindIndex(m => m.Guid == hdnGuid.Value.ToString());
//actSectionDetailsDto.RemoveAt(index);
if (index >= 0)
{
courtApplicationProceedingDetailsDto[index] = new CourtApplicationProceedingsDTO
{
Guid = Guid.NewGuid().ToString(),
DtOfInstitution = Convert.ToDateTime(txtDateOfInstitution.Text),
NextHearingDate = Convert.ToDateTime(txtNextDateOfHearing.Text),
ConductingOfficerType = (Int32)(string.IsNullOrEmpty(ddlConductingProsecutor.SelectedItem.Value) ? Convert.DBNull : Convert.ToInt32(ddlConductingProsecutor.SelectedItem.Value)),
LawOfficerId = (Int32)(string.IsNullOrEmpty(ddlLawOfficer.SelectedItem.Value) ? Convert.DBNull : Convert.ToInt32(ddlLawOfficer.SelectedItem.Value)),
NameSplCounsel = txtNameOfSpecialCounsel.Text,
HandlingSince = Convert.ToDateTime(txtHandlingSince.Text),
//OfficeID = CurrentUser.OfficeId,
IsActive = false
//CreatedBy = CurrentUser.UserId,
//CreatedDate = DateTime.Now,
//CreatedIPAddress = CurrentUser.IpAddress,
//UpdatedBy = CurrentUser.UserId,
//UpdatedDate = DateTime.Now,
//UpdatedIPAddress = CurrentUser.IpAddress,
};
}
courtApplicationProceedingDetailsDto.InsertRange(index, proceedingDetailsList);
}
else if (hdnGuidDataId.Value == "" && isExist == 0)
{
int count = courtApplicationProceedingDetailsDto.Count;
courtApplicationProceedingDetailsDto.InsertRange(count, proceedingDetailsList);
}
if (isExist == 0)
{
loadCourtApplicationProceedingsData(courtApplicationProceedingDetailsDto);
ClearControls();
}
ScriptManager.RegisterStartupScript(formUpdatePanelProceedingDetails, formUpdatePanelProceedingDetails.GetType(), Guid.NewGuid().ToString(), String.Format("HideSctionOfLawModals('" + modal_Proceeding.ClientID + "');"), true);
gridUpdatePanel.Update();
formUpdatePanelProceedingDetails.Update();
}
----------------------------
Edit functionality aspx.cs
protected void lnkEdit_Click(object sender, EventArgs e)
{
var lnkEdit = (LinkButton)sender;
string editId = lnkEdit.CommandArgument.ToString();
var lnkEditItem = (RepeaterItem)lnkEdit.NamingContainer;
UpdatePanel editUpdatePanel = (UpdatePanel)lnkEditItem.FindControl("editUpdatePanel");
LoadGui(editId);
gridUpdatePanel.Update();
formUpdatePanelProceedingDetails.Update();
}
public void LoadGui(string recordId)
{
var courtApplicationProceedingDetailsDto = GetAllCourtApplicationProceedingsData();
var proceedingDetails = courtApplicationProceedingDetailsDto.FirstOrDefault(m => m.Guid == recordId);
txtDateOfInstitution.Text = proceedingDetails.DtOfInstitution.ToString();
txtNextDateOfHearing.Text = proceedingDetails.NextHearingDate.ToString();
ddlConductingProsecutor.SelectedValue = Convert.ToString(proceedingDetails.ConductingOfficerType);
//ddlLawOfficer.SelectedValue = Convert.ToString(proceedingDetails.LawOfficerId);
txtNameOfSpecialCounsel.Text = proceedingDetails.NameSplCounsel;
txtHandlingSince.Text = proceedingDetails.HandlingSince.ToString();
hdnGuid.Value = proceedingDetails.Guid;
hdnGuidDataId.Value = proceedingDetails.Guid;
ScriptManager.RegisterStartupScript(formUpdatePanelProceedingDetails, formUpdatePanelProceedingDetails.GetType(), Guid.NewGuid().ToString(), String.Format("OpenProceedingModals('" + modal_Proceeding.ClientID + "');"), true);
UpdatePanelProceedingFormModel.Update();
formUpdatePanelProceedingDetails.Update();
}
For Deleting from repeater functionality
protected void lnkDelete_Click(object sender, EventArgs e)
{
var lnkDelete = (LinkButton)sender;
string deleteId = lnkDelete.CommandArgument.ToString();
var lnkDeleteItem = (RepeaterItem)lnkDelete.NamingContainer;
UpdatePanel deleteUpdatePanel = (UpdatePanel)lnkDeleteItem.FindControl("deleteUpdatePanel");
hdnGuidProceedingId.Value = deleteId;
ScriptManager.RegisterStartupScript(gridUpdatePanel, gridUpdatePanel.GetType(), Guid.NewGuid().ToString(), String.Format("OpenManageStatementDeleteModal('" + ManageStatementDelete.ClientID + "');"), true);
deleteUpdatePanel.Update();
formUpdatePanelProceedingDetails.Update();
}
protected void btnDelete_Click(object sender, EventArgs e)
{
var courtAppProceedingsDto = GetAllCourtApplicationProceedingsData();
int index = courtAppProceedingsDto.FindIndex(m => m.Guid == hdnGuidProceedingId.Value);
if (index >= 0)
{
if (courtAppProceedingsDto[index].Id == 0)
{
courtAppProceedingsDto.RemoveAt(index);
}
else
{
courtAppProceedingsDto[index].IsActive = false;
}
loadCourtApplicationProceedingsData(courtAppProceedingsDto);
gridUpdatePanel.Update();
SetFadeMesssage("The record was successfully removed!");
formUpdatePanelProceedingDetails.Update();
}
LoadCourtApplicationProceedings();
formUpdatePanelProceedingDetails.Update();
}
No comments:
Post a Comment