private void UpdateStock() { try { t_transferIn_detail trans = new t_transferIn_detail(); trans.transinrNo = txt_no.Text.Trim(); List <t_transferIn_detail> Transins = new List <t_transferIn_detail>(); Transins = new T_transferIn_detailDL().SelectT_transferIn_detailMulti(trans); foreach (t_transferIn_detail det in Transins) { //reduce stock from this location T_StockDL.AddStock_Update(det.stockCode, commonFunctions.GlobalCompany, commonFunctions.GlobalLocation, det.quantity.Value); //update stock on destination if (T_StockDL.ExistingT_Stock_new(det.stockCode.Trim(), commonFunctions.GlobalCompany, txt_destinationLocId.Text.Trim())) { //modify is already has record T_StockDL.ReduceStock_Update(det.stockCode, commonFunctions.GlobalCompany, txt_destinationLocId.Text.Trim(), det.quantity.Value); } else { //insert T_Stock objt_Stock = new T_Stock(); objt_Stock.StockCode = det.stockCode; objt_Stock.Compcode = commonFunctions.GlobalCompany; objt_Stock.Locacode = commonFunctions.GlobalLocation; objt_Stock = new T_StockDL().Selectt_Stock_new(objt_Stock); T_StockDL.AddStock_Insert(objt_Stock, commonFunctions.GlobalCompany, txt_destinationLocId.Text.Trim(), det.quantity.Value); } } } catch (Exception ex) { commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); throw ex; } }
private void txt_code_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F2) { if (txt_destinationLocId.Text.Trim() == string.Empty) { errorProvider1.SetError(txt_destinationLocId, "Please enter destination location code"); return; } if (ActiveControl.Name.Trim() == txt_code.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["ProductStockFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["ProductStockSQL"].ToString() + " WHERE T_Stock.Locacode = '" + txt_destinationLocId.Text.Trim() + "'"; for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["ProductStockField" + m + ""].ToString(); } frmU_Search find = new frmU_Search(strSQL, strSearchField, this); find.ShowDialog(this); } errorProvider1.Clear(); } if (e.KeyCode == Keys.Enter) { try { //txt_code.Text = commonFunctions.GetProcutCode(txt_code.Text.Trim()); if (T_StockDL.ExistingT_Stock_new(txt_code.Text, commonFunctions.GlobalCompany, commonFunctions.GlobalLocation)) { if (!commonFunctions.IsExist(dataGridView1, txt_code.Text)) { GetStockdetails(txt_destinationLocId.Text.Trim()); txt_qty.Text = "0"; txt_qty.Focus(); errorProvider1.Clear(); already = false; } else { already = true; GetStockdetails(txt_destinationLocId.Text.Trim()); DataGridViewRow drowx = new DataGridViewRow(); drowx = commonFunctions.GetRow(dataGridView1, txt_code.Text.Trim()); txt_qty.Text = drowx.Cells["Quntity"].Value.ToString(); txt_qty.Focus(); } } else { errorProvider1.SetError(txt_code, "Product you have entered not exist in the bin card"); commonFunctions.SetMDIStatusMessage("Product you have entered not exist in the bin card", 1); } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error", 1); throw ex; } } }