public StockDispatchDetail SaveDispatchDetail(StockDispatchDetail ObjStockDispatchDetail) { int StockDispatchDetailID = 0; try { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_CU_STOCKDISPATCHDETAIL]"; cmd.Parameters.AddWithValue("@STOCKDISPATCHDETAILID", ObjStockDispatchDetail.STOCKDISPATCHDETAILID); cmd.Parameters.AddWithValue("@STOCKDISPATCHID", ObjStockDispatchDetail.STOCKDISPATCHID); cmd.Parameters.AddWithValue("@ITEMPRICEID", ObjStockDispatchDetail.ITEMPRICEID); cmd.Parameters.AddWithValue("@TRAYNUMBER", ObjStockDispatchDetail.TRAYNUMBER); cmd.Parameters.AddWithValue("@DISPATCHQUANTITY", ObjStockDispatchDetail.DISPATCHQUANTITY); cmd.Parameters.AddWithValue("@WEIGHTINKGS", ObjStockDispatchDetail.WEIGHTINKGS); cmd.Parameters.AddWithValue("@USERID", ObjStockDispatchDetail.UserID); object objReturn = cmd.ExecuteScalar(); string str = Convert.ToString(objReturn); if (!int.TryParse(str, out StockDispatchDetailID)) { throw new Exception(str); } else { ObjStockDispatchDetail.STOCKDISPATCHDETAILID = StockDispatchDetailID; } } } catch (Exception ex) { throw new Exception("Error While Saving Dispatch Detail"); } finally { SQLCon.Sqlconn().Close(); } return(ObjStockDispatchDetail); }
private void txtQuantity_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == (char)Keys.Enter) { if (!dxValidationProvider2.Validate()) { return; } if (Convert.ToInt32(ObjStockDispatch.STOCKDISPATCHID) == 0) { SaveDispatch(); } ObjStockDispatchDetail = new StockDispatchDetail(); ObjStockDispatchDetail.STOCKDISPATCHDETAILID = 0; ObjStockDispatchDetail.STOCKDISPATCHID = ObjStockDispatch.STOCKDISPATCHID; ObjStockDispatchDetail.ITEMPRICEID = ItemPriceID; ObjStockDispatchDetail.TRAYNUMBER = txtTrayNumber.EditValue; ObjStockDispatchDetail.DISPATCHQUANTITY = txtQuantity.EditValue; ObjStockDispatchDetail.WEIGHTINKGS = txtWeightInKgs.EditValue; ObjStockDispatchDetail.UserID = Utility.UserID; ObjStockRep.SaveDispatchDetail(ObjStockDispatchDetail); RefreshGrid(); ObjStockDispatchDetail.STOCKDISPATCHDETAILID = 0; cmbItemCode.EditValue = null; txtItemName.EditValue = null; txtMRP.EditValue = null; txtSalePrice.EditValue = null; txtQuantity.EditValue = null; txtWeightInKgs.EditValue = null; cmbItemCode.Focus(); } } catch (Exception ex) { ErrorMgmt.ShowError(ex); ErrorMgmt.Errorlog.Error(ex); } }