protected void btnDCSelect_Click(object sender, EventArgs e) { string sql = "select * from DCMaster where DealerCode='" + Session["DealerCode"].ToString() + "' And DCNo='" + ddDCNumber.Text + "'"; DataTable dt = myFunc.GetData(sql); if (dt.Rows.Count > 0) { dpDCDate.Date = Convert.ToDateTime(dt.Rows[0]["DCDate"].ToString()); ddPONumber.Text = dt.Rows[0]["PONo"].ToString(); ddPONumber.Visible = false; lblPONo.Visible = true; lblPONo.Text = dt.Rows[0]["PONo"].ToString(); this.Session["PONumber"] = dt.Rows[0]["PONo"].ToString(); txtVendorDCNo.Text = dt.Rows[0]["VendorDCNo"].ToString(); txtRemarks.Text = dt.Rows[0]["Remarks"].ToString(); this.Session["DCNumber"] = ddDCNumber.Text; LoadPOInfo(lblPONo.Text); //btnPOSelect_Click(btnPOSelect, EventArgs.Empty); // loading details of DC DataSet ds = new DataSet(); ds = (DataSet)this.Session["DCDataSet"]; ds.Tables["DCItems"].Rows.Clear(); dt = myFunc.GetData("select * from DCDetail where DealerCode='" + Session["DealerCode"].ToString() + "' And DCNo='" + ddDCNumber.Text + "'"); if (dt.Rows.Count != 0) { foreach (DataRow dRow in dt.Rows) { DataRow row = ds.Tables["DCItems"].NewRow(); row["Sno"] = ds.Tables["DCItems"].Rows.Count + 1; row["PartItemNo"] = myFunc.GetPartItemNoByItemCode(dRow["ItemCode"].ToString()); row["PartItemName"] = myFunc.GetItemDescByItemCode(dRow["ItemCode"].ToString()); row["unit"] = myFunc.GetUnitDescByPartItemNo(row["PartItemNo"].ToString()); row["POQuantity"] = dRow["POQty"].ToString(); row["BalanceQuantity"] = dRow["BalQty"].ToString(); row["DCQuantity"] = dRow["DCQty"].ToString(); row["Selected"] = true; ds.Tables["DCItems"].Rows.Add(row); } } Session["DCDataSet"] = ds; GridViewDC.DataSource = ds; GridViewDC.DataBind(); btnDelete.Enabled = true; lblDCStatus.Text = "Edited"; } else { lblMSG.Text = "DC number not found"; return; } }
protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) { string[] parameters = e.Parameter.Split('|'); string row = parameters[0].ToString(); string itemno = parameters[1].ToString(); decimal balqty = Convert.ToDecimal(parameters[2].ToString()); decimal dcqty = Convert.ToDecimal(parameters[3].ToString()); DataSet ds = (DataSet)this.Session["DCDataSet"]; DataTable dt = ds.Tables["DCItems"]; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["PartItemNo"].ToString() == itemno) { if (dcqty > balqty) { dt.Rows[i]["DCQuantity"] = "0"; } else { dt.Rows[i]["DCQuantity"] = dcqty.ToString(); } dt.AcceptChanges(); break; } } this.Session["DCDataSet"] = ds; GridViewDC.DataSource = ds; GridViewDC.DataBind(); //ASPxGridView myg = GridViewDC; //string balqty = myg.GetRowValues(Convert.ToInt16(row),"BalanceQuantity").ToString(); //GridViewDC.GetRowValues(GridViewDC.FocusedRowIndex, "DCQuantity").ToString(); //lblMSG.Text = "Error"; //PopupControlMSG.ShowOnPageLoad = true; //GridViewDC.CancelEdit(); }
private void UpdateGrid(string PartItemNo, bool ChkVal) { DataSet ds = (DataSet)Session["DCDataSet"]; ASPxGridView gridView = GridViewDC; DataTable dataTable = ds.Tables[0]; DataRow row = dataTable.Rows.Find(PartItemNo); row["Selected"] = ChkVal; ds.Tables[0].AcceptChanges(); //IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator(); //enumerator.Reset(); //while (enumerator.MoveNext()) // row[enumerator.Key.ToString()] = enumerator.Value; Session["DCDataSet"] = ds; GridViewDC.DataSource = ds; GridViewDC.DataBind(); }
protected void GridViewDC_RowUpdating1(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { DataSet ds = (DataSet)Session["DCDataSet"]; decimal dqty = Convert.ToDecimal(e.NewValues["DCQuantity"].ToString()); decimal bqty = Convert.ToDecimal(e.NewValues["BalanceQuantity"].ToString()); if (dqty > bqty || dqty < 0) { ErrorMsg.Text = "Check quantity, you can't enter more than balance qty"; ErrorMsg.Visible = true; e.Cancel = true; GridViewDC.DataSource = ds; GridViewDC.DataBind(); return; } ASPxGridView gridView = (ASPxGridView)sender; DataTable dataTable = ds.Tables[0]; DataRow row = dataTable.Rows.Find(e.Keys[0]); IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator(); enumerator.Reset(); while (enumerator.MoveNext()) { row[enumerator.Key.ToString()] = enumerator.Value; } gridView.CancelEdit(); e.Cancel = true; Session["DCDataSet"] = ds; GridViewDC.DataSource = ds; GridViewDC.DataBind(); return; ////string test = GridViewDC.GetRowValues(GridViewDC.FocusedRowIndex,"DCQuantity").ToString(); //GridViewDC.CancelEdit(); //e.Cancel = true; }
private void LoadGrid(string DCNumber, string PONumber, string DealerCode) { DataTable dtParts = new DataTable(); DataSet ds = new DataSet(); DataSet dsParts = new DataSet(); SqlDataReader dr = null; string mPONo = ""; string mDCNo = ""; if (PONumber == "") { mPONo = this.Session["PONumber"].ToString(); } else { mPONo = PONumber; } //if (DCNumber == "") //{ // mDCNo = this.Session["DCNumber"].ToString(); //} //else //{ // mDCNo = DCNumber; //} try { SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 10), new SqlParameter("@PONO", SqlDbType.Char, 10) }; param[0].Value = this.Session["DealerCode"].ToString(); param[1].Value = mPONo; myFunc.ExecuteSP("Sp_2W_GetPO_ForDC", param, ref dr); dtParts.Load(dr); //ds = (DataSet)ViewState["ObjPOds"]; ds = (DataSet)this.Session["DCDataSet"]; ds.Tables["DCItems"].Rows.Clear(); if (dtParts.Rows.Count != 0) { foreach (DataRow dRow in dtParts.Rows) { SqlParameter[] paramPO_Parts = { new SqlParameter("@PONO", SqlDbType.Char, 10), new SqlParameter("@DealerCode", SqlDbType.Char, 10), new SqlParameter("@ItemCode", SqlDbType.Char, 10) }; paramPO_Parts[0].Value = mPONo; paramPO_Parts[1].Value = this.Session["DealerCode"].ToString(); paramPO_Parts[2].Value = dRow["ItemCode"].ToString(); dsParts = myFunc.FillDataSet("SP_Spare_Get_PartPOInfo", paramPO_Parts); DataRow row = ds.Tables["DCItems"].NewRow(); row["Sno"] = ds.Tables["DCItems"].Rows.Count + 1; row["PartItemNo"] = myFunc.GetStringValuesAgainstCodes("ItemCode", paramPO_Parts[2].Value.ToString(), "PartItemNo", "Item"); row["PartItemName"] = myFunc.GetStringValuesAgainstCodes("ItemCode", paramPO_Parts[2].Value.ToString(), "ItemDesc", "Item"); row["unit"] = myFunc.GetStringValuesAgainstCodes("UnitCode='" + dRow["UnitCode"].ToString() + "'", "unit", "UnitDesc"); row["POQuantity"] = dsParts.Tables[0].Rows[0]["POQty"].ToString(); row["BalanceQuantity"] = dsParts.Tables[0].Rows[0]["BalanceQty"].ToString(); if (DCNumber == "") { row["DCQuantity"] = dsParts.Tables[0].Rows[0]["BalanceQty"].ToString(); } else { row["DCQuantity"] = myFunc.GetDCQty(DCNumber, dRow["ItemCode"].ToString()); } row["Selected"] = true; ds.Tables["DCItems"].Rows.Add(row); } //if (GridViewDC.VisibleRowCount > 0) //{ // CheckBox chkSelect; // TextBox txtDCQty; // Label lblBalQty; // foreach (GridViewRow gvr in GridViewDC.Rows) // { // chkSelect = (CheckBox)gvr.Cells[0].FindControl("ChkSelect"); // txtDCQty = (TextBox)gvr.Cells[6].FindControl("txtDCQuantity"); // lblBalQty = (Label)gvr.Cells[5].FindControl("LbBalanceQuantity"); // chkSelect.Checked = true; // txtDCQty.Text = lblBalQty.Text; // //chkSelect.Enabled = false; // } //} //txtVendorNo.Text = dsVendorInfo.Tables[0].Rows[0]["vendorCode"].ToString(); //txtVendorDesc.Text = dsVendorInfo.Tables[0].Rows[0]["vendorDesc"].ToString(); } Session["DCDataSet"] = ds; GridViewDC.DataSource = ds.Tables["DCItems"]; GridViewDC.DataSourceID = null; GridViewDC.DataBind(); } catch (Exception ex) { //ObjGeneral.UserMsg(LbErr, Color.Red, "Error: " + ex.Message, txtDCNo); } }