private void BindGrid() { //try //{ FreightMemoDAL obj = new FreightMemoDAL(); Int32 iTocityIdno = (drpToCity.SelectedIndex <= 0 ? 0 : Convert.ToInt32(drpToCity.SelectedValue)); string UserClass = Convert.ToString(Session["Userclass"]); Int32 UserIdno = 0; if (UserClass != "Admin") { UserIdno = Convert.ToInt32(Session["UserIdno"]); } DataSet DsDetl = obj.SearchFreightReport(Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)), iTocityIdno, Convert.ToInt32(ddlDateRange.SelectedValue), UserIdno, ApplicationFunction.ConnectionString()); if ((DsDetl != null) && (DsDetl.Tables[0].Rows.Count > 0)) { ViewState["CSVdt"] = DsDetl.Tables[0]; grdMain.DataSource = DsDetl.Tables[0]; grdMain.DataBind(); //prints.Visible = true; imgBtnExcel.Visible = true; lblTotalRecord.Text = "Total Record (s): " + DsDetl.Tables[0].Rows.Count; } else { grdMain.DataSource = null; grdMain.DataBind(); //prints.Visible = false; imgBtnExcel.Visible = false; lblTotalRecord.Text = "Total Record (s): 0 "; } }
protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer == null) { base.AutoRedirect(); } SessionValues svalue = new SessionValues(); // base.UsessionValue = svalue.FetchUsersAndComp(string.IsNullOrEmpty(Convert.ToString(Session["Visageuseridno"])) ? 0 : Convert.ToInt32(Session["Visageuseridno"])); // conString = ConfigurationManager.ConnectionStrings["VisageConnectionString"].ToString(); svalue = null; if (!Page.IsPostBack) { this.Title = "Manage Freight Memo"; this.BindDateRange(); ddlDateRange.SelectedIndex = 0; ddlDateRange_SelectedIndexChanged(null, null); if (Convert.ToString(Session["Userclass"]) == "Admin") { this.BindCity(); } else { this.BindCity(Convert.ToInt64(Session["UserIdno"])); } FreightMemoDAL objChallanDelverdDAL = new FreightMemoDAL(); txtDateFrom.Attributes.Add("onkeypress", "return notAllowAnything(event);"); txtDateTo.Attributes.Add("onkeypress", "return notAllowAnything(event);"); Countall(); ddlDateRange.Focus(); } }
protected void lnkbtnSearch_OnClick(object sender, EventArgs e) { try { FreightMemoDAL obj = new FreightMemoDAL(); Int32 iToCityIdno = (ddlToCity.SelectedIndex <= 0 ? 0 : Convert.ToInt32(ddlToCity.SelectedValue)); string strAction = ""; string StrGrno = ""; StrGrno = txtSrchGrNo.Text; DataTable DsGrdetail = obj.selectGrDetails("SelectGRDetail", Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFromDiv.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateToDiv.Text)), StrGrno, ApplicationFunction.ConnectionString(), iToCityIdno); if ((DsGrdetail != null) && (DsGrdetail.Rows.Count > 0)) { grdGrdetals.DataSource = DsGrdetail; grdGrdetals.DataBind(); lnkbtnSubmitok.Visible = true; btnbtnClear.Visible = true; } else { grdGrdetals.DataSource = null; grdGrdetals.DataBind(); lnkbtnSubmitok.Visible = false; btnbtnClear.Visible = false; } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "openModal();", true); } catch (Exception Ex) { ApplicationFunction.ErrorLog(Ex.Message); } }
protected void lnkbtnSubmitok_OnClick(object sender, EventArgs e) { try { Int32 iRateType = 0; double dcommssn = 0, dweight = 0, dqty = 0, dtotcommssn = 0; if ((grdGrdetals != null) && (grdGrdetals.Rows.Count > 0)) { string strchkValue = string.Empty; string sAllItemIdnos = string.Empty; string strchkDetlValue = string.Empty; Int32 Count = 0; for (int count = 0; count < grdGrdetals.Rows.Count; count++) { CheckBox ChkGr = (CheckBox)grdGrdetals.Rows[count].FindControl("chkId"); if ((ChkGr != null) && (ChkGr.Checked == true)) { HiddenField hidGrIdno = (HiddenField)grdGrdetals.Rows[count].FindControl("hidGrIdno"); strchkDetlValue = strchkDetlValue + hidGrIdno.Value + ","; Count = Count + 1; } } if (strchkDetlValue != "") { strchkDetlValue = strchkDetlValue.Substring(0, strchkDetlValue.Length - 1); } if (strchkDetlValue == "") { ShowMessageErr("Please select atleast one Gr."); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "openModal();", true); return; } if (Count > 1) { ShowMessageErr("Please select only one Gr. at a time"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "openModal();", true); return; } else { FreightMemoDAL ObjFreightMemoDAL = new FreightMemoDAL(); string strSbillNo = String.Empty; DataTable dtRcptDetl = new DataTable(); DataRow Dr; dtRcptDetl = ObjFreightMemoDAL.SelectGRDetailInRcpt(ApplicationFunction.ConnectionString(), Convert.ToInt32(ddldateRange.SelectedValue), Convert.ToString(strchkDetlValue)); ViewState["dt"] = dtRcptDetl; BindValues(dtRcptDetl); grdGrdetals.DataSource = null; grdGrdetals.DataBind(); } } else { ShowMessageErr("Gr Details not found."); ShowDiv("ShowBillAgainst('dvGrdetails')"); } } catch (Exception Ex) { ApplicationFunction.ErrorLog(Ex.Message); } }
public void Countall() { FreightMemoDAL obj = new FreightMemoDAL(); Int64 count = obj.Countall(); if (count > 0) { lbltotalstaff.Text = "T. Record (s):" + count; } }
protected void grdUser_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "cmdEdit") { Response.Redirect("FreightMemo.aspx?Freightidno=" + e.CommandArgument, true); } else if (e.CommandName == "cmddelete") { FreightMemoDAL objChallanDelverdDAL = new FreightMemoDAL(); long value = objChallanDelverdDAL.DeleteALL(Convert.ToInt64(e.CommandArgument)); objChallanDelverdDAL = null; if (value > 0) { this.Populate(); } } }
private void Populate() { string action = string.Empty; DateTime?dateFrom = null; DateTime?dateTo = null; string transferno = ""; Int32 rcptno = 0; int yearIdno = Convert.ToInt32(ddlDateRange.SelectedValue); if (txtDateFrom.Text != "") { dateFrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)); } else { dateFrom = null; } if (txtDateTo.Text != "") { dateTo = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)); } else { dateTo = null; } rcptno = (Convert.ToString(txtRcptNo.Text) != "" ? Convert.ToInt32(txtRcptNo.Text) : 0); Int32 ToCity = Convert.ToInt32(ddlTocity.SelectedValue); FreightMemoDAL objChallanDelverdDAL = new FreightMemoDAL(); var lst = objChallanDelverdDAL.Search(dateFrom, dateTo, rcptno, ToCity, yearIdno); objChallanDelverdDAL = null; grdUser.DataSource = lst; grdUser.DataBind(); lbltotalstaff.Text = "T. Record (s): " + lst.Count; if (lst != null && lst.Count > 0) { DataTable dt = new DataTable(); dt.Columns.Add("SrNo", typeof(string)); dt.Columns.Add("RecptDate", typeof(string)); dt.Columns.Add("RecpNo", typeof(string)); dt.Columns.Add("ToCity", typeof(string)); dt.Columns.Add("NetAmount", typeof(string)); double TNet = 0; for (int i = 0; i < lst.Count; i++) { DataRow dr = dt.NewRow(); dr["SrNo"] = Convert.ToString(i + 1); dr["RecptDate"] = Convert.ToDateTime(DataBinder.Eval(lst[i], "Rcpt_Date")).ToString("dd-MM-yyyy"); dr["RecpNo"] = Convert.ToString(DataBinder.Eval(lst[i], "Rcpt_No")); dr["ToCity"] = Convert.ToString(DataBinder.Eval(lst[i], "City_Name")); dr["NetAmount"] = Convert.ToString(DataBinder.Eval(lst[i], "Net_Amnt")); dt.Rows.Add(dr); TNet += Convert.ToDouble(DataBinder.Eval(lst[i], "Net_Amnt")); if (i == lst.Count - 1) { DataRow drr = dt.NewRow(); drr["ToCity"] = "Total"; drr["NetAmount"] = (TNet).ToString("N2"); dt.Rows.Add(drr); } } if (dt != null && dt.Rows.Count > 0) { ViewState["Dt"] = dt; } // Double TotalNetAmount = 0; for (int i = 0; i < lst.Count; i++) { TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lst[i], "Net_Amnt")); } lblNetTotalAmount.Text = TotalNetAmount.ToString("N2"); int startRowOnPage = (grdUser.PageIndex * grdUser.PageSize) + 1; int lastRowOnPage = startRowOnPage + grdUser.Rows.Count - 1; lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lst.Count.ToString(); lblcontant.Visible = true; divpaging.Visible = true; imgBtnExcel.Visible = true; } else { imgBtnExcel.Visible = false; lblcontant.Visible = false; divpaging.Visible = false; } }
protected void lnkbtnSave_OnClick(object sender, EventArgs e) { string strMsg = string.Empty; FreightMemoDAL objItemMast = new FreightMemoDAL(); Int64 intValue = 0; if ((txtGrNo.Text == "") && (ddlRecivr.SelectedIndex <= 0) && (txtQty.Text == "") && (txtWeight.Text == "") && (txtFreight.Text == "")) { ShowMessageErr("please Enter Details"); ddlToCity.Focus(); return; } tblFreightMemo objtblFreightMemo = new tblFreightMemo(); objtblFreightMemo.Rcpt_Date = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtGRDate.Text)); objtblFreightMemo.Rcpt_No = Convert.ToInt64(txtRcptNo.Text); objtblFreightMemo.ToCity_Idno = Convert.ToInt64(ddlToCity.SelectedValue); objtblFreightMemo.Gr_No = Convert.ToInt64(txtGrNo.Text); objtblFreightMemo.Receiver_Idno = Convert.ToInt64(ddlRecivr.SelectedValue); objtblFreightMemo.Tot_Qty = Convert.ToInt64(txtQty.Text); objtblFreightMemo.Tot_Weight = Convert.ToDouble(txtWeight.Text); objtblFreightMemo.Freight_Amnt = Convert.ToDouble(txtFreight.Text); objtblFreightMemo.Service_Amnt = Convert.ToDouble(txtServiceCharg.Text); objtblFreightMemo.Labour_Amnt = Convert.ToDouble(txtLabbrCharg.Text); objtblFreightMemo.Delivery_Amnt = Convert.ToDouble(txtDelvAmnt.Text); objtblFreightMemo.Octrai_Amnt = Convert.ToDouble(txtOctraiAmnt.Text); objtblFreightMemo.Damage_Amnt = Convert.ToDouble(txtDamage.Text); objtblFreightMemo.Net_Amnt = Convert.ToDouble(txtNetTotal.Text); objtblFreightMemo.GR_Idno = Convert.ToInt64(hidGrIdno.Value); objtblFreightMemo.Year_Idno = Convert.ToInt64(ddldateRange.SelectedValue); objtblFreightMemo.Remarks = Convert.ToString(txtremark.Text); if (string.IsNullOrEmpty(hidItemidno.Value) == true) { intValue = objItemMast.Insert(objtblFreightMemo); } else { intValue = objItemMast.Update(objtblFreightMemo, Convert.ToInt64(hidItemidno.Value)); } objItemMast = null; if (intValue > 0) { if (string.IsNullOrEmpty(hidItemidno.Value) == false) { strMsg = "Record updated successfully."; } else { strMsg = "Record saved successfully."; } this.ClearControls(); } else if (intValue < 0) { strMsg = "Record already exists."; } else { if (string.IsNullOrEmpty(hidItemidno.Value) == false) { strMsg = "Record not updated."; } else { strMsg = "Record not saved."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); txtRcptNo.Focus(); }