private void frmStockDispatch_Load(object sender, EventArgs e) { try { ((frmMain)MdiParent).RefreshBaseLineData += FrmStockDispatch_RefreshBaseLineData; DataTable dtBranch = ObjMasterRep.GetBranch(); DataView dvBranch = dtBranch.Copy().DefaultView; dvBranch.RowFilter = "ISWAREHOUSE = 0"; cmbToBranch.Properties.DataSource = dvBranch; cmbToBranch.Properties.ValueMember = "BRANCHID"; cmbToBranch.Properties.DisplayMember = "BRANCHNAME"; DataView gvWarehouse = dtBranch.Copy().DefaultView; gvWarehouse.RowFilter = "ISWAREHOUSE = 1"; cmbFromBranch.Properties.DataSource = gvWarehouse; cmbFromBranch.Properties.ValueMember = "BRANCHID"; cmbFromBranch.Properties.DisplayMember = "BRANCHNAME"; cmbItemCode.Properties.DataSource = Utility.GetItemCodeListFiltered(); cmbItemCode.Properties.ValueMember = "ITEMCODEID"; cmbItemCode.Properties.DisplayMember = "ITEMCODE"; if (ObjStockDispatch == null) { ObjStockDispatch = new StockDispatch(); } ObjStockDispatch.UserID = Utility.UserID; ObjStockDispatch.CATEGORYID = Utility.CategoryID; ObjStockRep.GetDispatchDraft(ObjStockDispatch); if (Convert.ToInt32(ObjStockDispatch.STOCKDISPATCHID) > 0) { cmbFromBranch.EditValue = ObjStockDispatch.FROMBRANCHID; cmbToBranch.EditValue = ObjStockDispatch.TOBRANCHID; gcDispatch.DataSource = ObjStockDispatch.dtDispatch; cmbFromBranch.Enabled = false; cmbToBranch.Enabled = false; } else { ObjStockDispatch.dtDispatch = new DataTable(); ObjStockDispatch.dtDispatch.Columns.Add("STOCKDISPATCHDETAILID", typeof(int)); ObjStockDispatch.dtDispatch.Columns.Add("ITEMID", typeof(int)); ObjStockDispatch.dtDispatch.Columns.Add("ITEMCODEID", typeof(int)); ObjStockDispatch.dtDispatch.Columns.Add("ITEMPRICEID", typeof(int)); ObjStockDispatch.dtDispatch.Columns.Add("SKUCODE", typeof(string)); ObjStockDispatch.dtDispatch.Columns.Add("ITEMCODE", typeof(string)); ObjStockDispatch.dtDispatch.Columns.Add("ITEMNAME", typeof(string)); ObjStockDispatch.dtDispatch.Columns.Add("MRP", typeof(decimal)); ObjStockDispatch.dtDispatch.Columns.Add("SALEPRICE", typeof(decimal)); ObjStockDispatch.dtDispatch.Columns.Add("DISPATCHQUANTITY", typeof(int)); ObjStockDispatch.dtDispatch.Columns.Add("WEIGHTINKGS", typeof(decimal)); ObjStockDispatch.dtDispatch.Columns.Add("TRAYNUMBER", typeof(int)); gcDispatch.DataSource = ObjStockDispatch.dtDispatch; } } catch (Exception) { } }
public StockDispatch GetDispatchDraft(StockDispatch objStockDispatch) { try { DataSet ds = new DataSet(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_R_DISPATCHDRAFT]"; cmd.Parameters.AddWithValue("@CATEGORYID", objStockDispatch.CATEGORYID); cmd.Parameters.AddWithValue("@USERID", objStockDispatch.UserID); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string str = Convert.ToString(ds.Tables[0].Rows[0][0]); int iValue = 0; if (!int.TryParse(str, out iValue)) { objStockDispatch.STOCKDISPATCHID = 0; } else { objStockDispatch.STOCKDISPATCHID = iValue; objStockDispatch.FROMBRANCHID = ds.Tables[0].Rows[0]["FROMBRANCHID"]; objStockDispatch.TOBRANCHID = ds.Tables[0].Rows[0]["TOBRANCHID"]; objStockDispatch.dtDispatch = ds.Tables[1].Copy(); } } } } catch (Exception ex) { throw new Exception("Error While Reading Dispatch"); } finally { SQLCon.Sqlconn().Close(); } return(objStockDispatch); }
public void UpdateDispatch(StockDispatch ObjStockDispatch) { try { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_U_STOCKDISPATCH]"; cmd.Parameters.AddWithValue("@STOCKDISPATCHID", ObjStockDispatch.STOCKDISPATCHID); cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw new Exception("Error While Updating Dispatch"); } finally { SQLCon.Sqlconn().Close(); } }
private void SaveDispatch() { try { if (ObjStockDispatch == null) { ObjStockDispatch = new StockDispatch(); ObjStockDispatch.STOCKDISPATCHID = 0; } ObjStockDispatch.FROMBRANCHID = cmbFromBranch.EditValue; ObjStockDispatch.TOBRANCHID = cmbToBranch.EditValue; ObjStockDispatch.CATEGORYID = Utility.CategoryID; ObjStockDispatch.UserID = Utility.UserID; ObjStockRep.SaveDispatch(ObjStockDispatch); cmbFromBranch.Enabled = false; cmbToBranch.Enabled = false; } catch (Exception ex) { throw ex; } }
public StockDispatch SaveDispatch(StockDispatch ObjStockDispatch) { int StockDispatchID = 0; try { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_CU_STOCKDISPATCH]"; cmd.Parameters.AddWithValue("@STOCKDISPATCHID", ObjStockDispatch.STOCKDISPATCHID); cmd.Parameters.AddWithValue("@FROMBRANCHID", ObjStockDispatch.FROMBRANCHID); cmd.Parameters.AddWithValue("@TOBRANCHID", ObjStockDispatch.TOBRANCHID); cmd.Parameters.AddWithValue("@CATEGORYID", ObjStockDispatch.CATEGORYID); cmd.Parameters.AddWithValue("@USERID", ObjStockDispatch.UserID); object objReturn = cmd.ExecuteScalar(); string str = Convert.ToString(objReturn); if (!int.TryParse(str, out StockDispatchID)) { throw new Exception(str); } else { ObjStockDispatch.STOCKDISPATCHID = objReturn; } } } catch (Exception ex) { throw new Exception("Error While Saving Dispatch"); } finally { SQLCon.Sqlconn().Close(); } return(ObjStockDispatch); }