protected void lnkBtnSave_Click(object sender, EventArgs e) { UpdateGrDetailDAL obj = new UpdateGrDetailDAL(); int count = 0; Int64 GrDetail = 0; Int64 qty = 0, GrNumber = 0; double Weight = 0; if (grdMain.Rows.Count <= 0) { ShowMessageErr("Please Enter Grid Details"); } else { CreateDt(); foreach (GridViewRow row in grdMain.Rows) { HiddenField hidGrIdno = (HiddenField)row.FindControl("hidGridno"); HiddenField hidItemidno = (HiddenField)row.FindControl("hidItemidno"); HiddenField hidUnitidno = (HiddenField)row.FindControl("hidUnitidno"); HiddenField hidGrdetlidno = (HiddenField)row.FindControl("hidGrdetlidno"); Label lblrateType = (Label)row.FindControl("lblrateType"); TextBox txtQty = (TextBox)row.FindControl("txtQty"); qty = Convert.ToInt64(txtQty.Text); TextBox txtWeight = (TextBox)row.FindControl("txtWeight"); Weight = Convert.ToDouble(txtWeight.Text); Label GRno = (Label)row.FindControl("lblGrNo"); GrNumber = Convert.ToInt64(GRno.Text); ApplicationFunction.DatatableAddRow(DtTemp, hidGrdetlidno.Value, hidGrIdno.Value, hidItemidno.Value, hidUnitidno.Value, ((lblrateType.Text) == "Rate") ? "1" : "2", qty, Weight); } if (qty > 0 && Weight > 0) { bool value = obj.UpdateGrDetl(DtTemp, Convert.ToInt64(ddlLocation.SelectedValue)); ShowMessage("Update Successfully"); } else { ShowMessageErr("Quanity and Weight Must Be Greater then Zero"); } } }
private void BindGrid() { if ((ddlLocation.SelectedIndex > 0) && (txtGrno.Text != "")) { UpdateGrDetailDAL obj = new UpdateGrDetailDAL(); DataSet Ds = obj.SelecGRdetl(ApplicationFunction.ConnectionString(), "SelectGrDetl", Convert.ToInt64(ddlLocation.SelectedValue), Convert.ToInt64(txtGrno.Text), Convert.ToInt32(ddlDateRange.SelectedValue)); obj = null; LocGrAmnt = 0; OutGrAmnt = 0; if (Ds != null && Ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in Ds.Tables[0].Rows) { Int32 DelvPlcIdno = Convert.ToInt32(dr["DelvryPlce_Idno"]); double dGrAmnt = Convert.ToDouble(dr["Amount"]); LocGrAmnt += dGrAmnt; OutGrAmnt += dGrAmnt; } } ViewState["dt"] = (DataTable)Ds.Tables[0]; grdMain.DataSource = ViewState["dt"]; grdMain.DataBind(); grdMain.Visible = true; obj = null; } else { grdMain.Visible = false; ddlLocation.SelectedIndex = 0; ddlLocation.Focus(); grdMain.DataSource = null; grdMain.DataBind(); ShowMessageErr("Enter Gr no & Location.."); } ; }