private void GetMaxMatIssueNo() { MaterialIssueAgnClaimDAL objMaterialIssueAgnClaimDAL = new MaterialIssueAgnClaimDAL(); txtMatIssNo.Text = objMaterialIssueAgnClaimDAL.GetMatIssueMax(string.IsNullOrEmpty(ddlFromCity.SelectedValue) ? 0 : Convert.ToInt64(ddlFromCity.SelectedValue), string.IsNullOrEmpty(txtPrefixNo.Text.Trim()) ? "" : Convert.ToString(txtPrefixNo.Text.Trim()), Convert.ToInt64(ddlDateRange.SelectedValue)).ToString(); objMaterialIssueAgnClaimDAL = null; }
private void Populate(Int64 HeadIdno) { MaterialIssueAgnClaimDAL objMaterialIssueAgnClaimDAL = new MaterialIssueAgnClaimDAL(); tblMatIssueAgnClaimHead ObjHead = objMaterialIssueAgnClaimDAL.SelectHead(HeadIdno); if (ObjHead != null) { hidid.Value = HeadIdno.ToString(); ddlDateRange.SelectedValue = Convert.ToString(ObjHead.Year_Idno); txtPrefixNo.Text = ObjHead.Prefix_No.ToString(); txtMatIssClaimDate.Text = string.IsNullOrEmpty(ObjHead.MatIssAgnClaimHead_Date.ToString()) ? "" : Convert.ToDateTime(ObjHead.MatIssAgnClaimHead_Date).ToString("dd-MM-yyyy"); txtMatIssNo.Text = string.IsNullOrEmpty(ObjHead.MatIss_No.ToString()) ? "" : Convert.ToString(ObjHead.MatIss_No); ddlFromCity.SelectedValue = string.IsNullOrEmpty(ObjHead.FromLoc_Idno.ToString()) ? "0" : Convert.ToString(ObjHead.FromLoc_Idno); ddlParty.SelectedValue = string.IsNullOrEmpty(ObjHead.Prty_Idno.ToString()) ? "0" : Convert.ToString(ObjHead.Prty_Idno); dtTemp = CreateDt(); //string Result = String.Empty; //var ClaimNo = objMaterialIssueAgnClaimDAL.SelectSaleBillNo(Convert.ToInt64(HeadIdno)); if (ClaimNo != null && ClaimNo > 0) { lblSbillNo.Text = "Sale Bill No : " + ClaimNo.ToString(); } var lst = objMaterialIssueAgnClaimDAL.SelectClaimDetails(HeadIdno); if (lst != null && lst.Count > 0) { grdMain.DataSource = lst; grdMain.DataBind(); grdMain.Visible = true; } } }
protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { string strMsg = string.Empty; if (e.CommandName == "cmdEdit") { Response.Redirect("MaterialIssueAgnClaim.aspx?MatIssIdno=" + e.CommandArgument, true); } else if (e.CommandName == "cmddelete") { MaterialIssueAgnClaimDAL obj = new MaterialIssueAgnClaimDAL(); long intValue = obj.Delete(Convert.ToInt32(e.CommandArgument)); obj = null; if (intValue > 0) { this.BindGrid(); strMsg = "Record deleted successfully."; } else { if (intValue == -1) { strMsg = "Record can not be deleted. It is in use!"; } else { strMsg = "Record not deleted."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } }
protected void lnkbtnSearch_OnClick(object sender, EventArgs e) { if (txtCalimNo.Text == "" && ddlDivPrtyName.SelectedValue == "0") { DivErrorMsg.Visible = true; lblDivErrorMsg.InnerText = "* Please Select Claim Number or Party."; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "openGridDetail();", true); return; } else { grdSearchRecords.Visible = true; MaterialIssueAgnClaimDAL objMaterialIssueAgnClaimDAL = new MaterialIssueAgnClaimDAL(); DataTable dt = CreateDivDt(); Int32 intyearid = Convert.ToInt32(ddlDateRange.SelectedValue); DateTime? DateFrom = null; DateTime?DateTo = null; DateFrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDivDateFrom.Text)); DateTo = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDivDateTo.Text)); Int64 Location = string.IsNullOrEmpty(Convert.ToString(ddlFromCity.SelectedValue)) ? 0 : Convert.ToInt64(ddlFromCity.SelectedValue); Int64 PartyIdno = string.IsNullOrEmpty(Convert.ToString(ddlDivPrtyName.SelectedValue)) ? 0 : Convert.ToInt64(ddlDivPrtyName.SelectedValue); string ClaimNo = (string.IsNullOrEmpty(Convert.ToString(txtCalimNo.Text.Trim())) ? "" : Convert.ToString(txtCalimNo.Text.Trim())) + "" + (string.IsNullOrEmpty(Convert.ToString(txtPrefixNo.Text.Trim())) ? "" : Convert.ToString(txtPrefixNo.Text.Trim())); var lst = objMaterialIssueAgnClaimDAL.SelectForSearch(DateFrom, DateTo, ClaimNo, PartyIdno, Location, intyearid); objMaterialIssueAgnClaimDAL = null; if (lst != null && lst.Count > 0) { for (int i = 0; i < lst.Count; i++) { string HeadIdno = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "HeadIdno"))) ? "" : Convert.ToString((DataBinder.Eval(lst[i], "HeadIdno"))); string HeadDate = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "HeadDate"))) ? "" : Convert.ToString(Convert.ToDateTime(DataBinder.Eval(lst[i], "HeadDate")).ToString("dd-MM-yyyy")); string PrefNo = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "PrefNo"))) ? "" : Convert.ToString(DataBinder.Eval(lst[i], "PrefNo")); string ClaimNumber = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "ClaimNo"))) ? "" : Convert.ToString(DataBinder.Eval(lst[i], "ClaimNo")); string PrtyName = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "PrtyName"))) ? "" : Convert.ToString(DataBinder.Eval(lst[i], "PrtyName")); string FromCityName = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "FromCityName"))) ? "" : Convert.ToString(DataBinder.Eval(lst[i], "FromCityName")); string CompName = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "CompName"))) ? "0" : Convert.ToString(DataBinder.Eval(lst[i], "CompName")); //string CompIdno = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "CompIdno"))) ? "0" : Convert.ToString(DataBinder.Eval(lst[i], "CompIdno")); //string FromCityIdno = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[i], "FromCityIdno"))) ? "" : Convert.ToString(DataBinder.Eval(lst[i], "FromCityIdno")); ApplicationFunction.DatatableAddRow(dt, i + 1, HeadIdno, ApplicationFunction.mmddyyyy(HeadDate), (PrefNo + "" + ClaimNumber), PrtyName, FromCityName, CompName); } HidHeadIdno.Value = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[0], "HeadIdno"))) ? "" : Convert.ToString(DataBinder.Eval(lst[0], "HeadIdno")); ddlParty.SelectedValue = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[0], "PrtyIdno"))) ? "" : Convert.ToString(DataBinder.Eval(lst[0], "PrtyIdno")); ViewState["dtDivGrid"] = dt; dt.Dispose(); this.BindDivGrid(); DivErrorMsg.Visible = false; lblDivErrorMsg.InnerText = ""; } else { DivErrorMsg.Visible = false; lblDivErrorMsg.InnerText = ""; } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "openGridDetail();", true); } }
private void BindGrid() { MaterialIssueAgnClaimDAL obj = new MaterialIssueAgnClaimDAL(); string ClaimNo = string.IsNullOrEmpty(Convert.ToString(txtClaimNo.Text)) ? "" : Convert.ToString(txtClaimNo.Text); Int64 YearIdno = string.IsNullOrEmpty(Convert.ToString(ddlDateRange.SelectedValue)) ? 0 : Convert.ToInt64(ddlDateRange.SelectedValue); Int64 PartyIdno = string.IsNullOrEmpty(Convert.ToString(ddlPartyName.SelectedValue)) ? 0 : Convert.ToInt64(ddlPartyName.SelectedValue); Int64 LocationFrom = string.IsNullOrEmpty(Convert.ToString(ddlLocation.SelectedValue)) ? 0 : Convert.ToInt64(ddlLocation.SelectedValue); DateTime?dtfrom = null; DateTime?dtto = null; if (string.IsNullOrEmpty(Convert.ToString(txtDateFrom.Text)) == false) { dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)); } if (string.IsNullOrEmpty(Convert.ToString(txtDateTo.Text)) == false) { dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)); } var lstGridData = obj.SearchList(dtfrom, dtto, ClaimNo, PartyIdno, LocationFrom, YearIdno); obj = null; if (lstGridData != null && lstGridData.Count > 0) { grdMain.DataSource = lstGridData; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count; imgBtnExcel.Visible = true; int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1; int lastRowOnPage = startRowOnPage + grdMain.Rows.Count - 1; lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString(); lblcontant.Visible = true; divpaging.Visible = true; } else { grdMain.DataSource = null; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): 0 "; imgBtnExcel.Visible = false; lblcontant.Visible = false; divpaging.Visible = false; } }
protected void lnkbtnSubmit_Click(object sender, EventArgs e) { try { MaterialIssueAgnClaimDAL objMaterialIssueAgnClaimDAL = new MaterialIssueAgnClaimDAL(); if ((grdSearchRecords != null) && (grdSearchRecords.Rows.Count > 0)) { string CalimIdDetlValue = string.Empty; for (int count = 0; count < grdSearchRecords.Rows.Count; count++) { CheckBox ChkGr = (CheckBox)grdSearchRecords.Rows[count].FindControl("chkId"); if ((ChkGr != null) && (ChkGr.Checked == true)) { HiddenField hidHeadIdno = (HiddenField)grdSearchRecords.Rows[count].FindControl("hidHeadIdno"); CalimIdDetlValue = CalimIdDetlValue + hidHeadIdno.Value + ","; } } if (CalimIdDetlValue != "") { CalimIdDetlValue = CalimIdDetlValue.Substring(0, CalimIdDetlValue.Length - 1); } if (CalimIdDetlValue == "") { ShowMessageErr("Please select atleast one Claim Number."); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "openGridDetail();", true); } else { var Lst = objMaterialIssueAgnClaimDAL.Select(Convert.ToInt32(ddlDateRange.SelectedValue), Convert.ToString(CalimIdDetlValue)); if (Lst != null && Lst.Count > 0) { grdMain.DataSource = Lst; grdMain.DataBind(); grdMain.Visible = true; } } } } catch (Exception Ex) { ApplicationFunction.ErrorLog(Ex.Message); } }
protected void lnkbtnSave_Click(object sender, EventArgs e) { string msg = ""; DateTime?ClaimDate = null; ClaimDate = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtMatIssClaimDate.Text)); MaterialIssueAgnClaimDAL objMaterialIssueAgnClaimDAL = new MaterialIssueAgnClaimDAL(); DateTime CurrentDate = System.DateTime.Now; if (grdMain.Rows.Count > 0) { DTMain = CreateDt(); foreach (GridViewRow row in grdMain.Rows) { HiddenField hidSerialIdno = (HiddenField)row.FindControl("hidSerialIdno"); ApplicationFunction.DatatableAddRow(DTMain, row.RowIndex + 1, hidSerialIdno.Value); } tblMatIssueAgnClaimHead objClaimHead = new tblMatIssueAgnClaimHead(); if (txtMatIssClaimDate.Text == "") { objClaimHead.MatIssAgnClaimHead_Date = null; } else { objClaimHead.MatIssAgnClaimHead_Date = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtMatIssClaimDate.Text)); } objClaimHead.MatIss_No = string.IsNullOrEmpty(Convert.ToString(txtMatIssNo.Text.Trim())) ? 0 : Convert.ToInt64(txtMatIssNo.Text.Trim()); objClaimHead.Prefix_No = string.IsNullOrEmpty(Convert.ToString(txtPrefixNo.Text.Trim())) ? "" : Convert.ToString(txtPrefixNo.Text.Trim()); objClaimHead.FromLoc_Idno = string.IsNullOrEmpty(Convert.ToString(ddlFromCity.SelectedValue)) ? 0 : Convert.ToInt64(ddlFromCity.SelectedValue); objClaimHead.Year_Idno = string.IsNullOrEmpty(Convert.ToString(ddlDateRange.SelectedValue)) ? 0 : Convert.ToInt64(ddlDateRange.SelectedValue); objClaimHead.Prty_Idno = string.IsNullOrEmpty(Convert.ToString(ddlParty.SelectedValue)) ? 0 : Convert.ToInt64(ddlParty.SelectedValue); objClaimHead.ClaimToComHead_Idno = string.IsNullOrEmpty(Convert.ToString(HidHeadIdno.Value)) ? 0 : Convert.ToInt64(HidHeadIdno.Value); Int64 value = 0; using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required)) { if (string.IsNullOrEmpty(hidid.Value) == true) { objClaimHead.Date_Added = System.DateTime.Now; value = objMaterialIssueAgnClaimDAL.Insert(objClaimHead, DTMain); objMaterialIssueAgnClaimDAL = null; } else { objClaimHead.Date_Modified = System.DateTime.Now; lnkbtnNew.Visible = false; value = objMaterialIssueAgnClaimDAL.Update(objClaimHead, Convert.ToInt32(hidid.Value), DTMain); objMaterialIssueAgnClaimDAL = null; } if (string.IsNullOrEmpty(hidid.Value) == false) { if (value > 0 && (string.IsNullOrEmpty(hidid.Value) == false)) { ShowMessage("Record Update successfully"); Clear(); tScope.Complete(); } else if (value == -1) { ShowMessageErr("Material Issue Number Already Exist"); tScope.Dispose(); } else { ShowMessageErr("Record Not Update"); tScope.Dispose(); } } else { if (value > 0 && (string.IsNullOrEmpty(hidid.Value) == true)) { ShowMessage("Record saved Successfully "); Clear(); tScope.Complete(); } else if (value == -1) { ShowMessageErr("Claim Number Already Exist"); tScope.Dispose(); } else { ShowMessageErr("Record Not saved Successfully "); tScope.Dispose(); } } } } else { ShowMessageErr("Please Search and Select Serial Number."); return; } }