private void UpdateStock() { try { t_adjustment_details trans = new t_adjustment_details(); trans.adju_no = txt_no.Text.Trim(); List <t_adjustment_details> Transins = new List <t_adjustment_details>(); Transins = new T_adjustment_detailDL().SelectT_adjustment_detailMulti(trans); foreach (t_adjustment_details det in Transins) { T_Stock objt_Stock = new T_Stock(); objt_Stock.StockCode = det.item_code; objt_Stock.Compcode = commonFunctions.GlobalCompany; objt_Stock.Locacode = commonFunctions.GlobalLocation; objt_Stock = new T_StockDL().Selectt_Stock_new(objt_Stock); decimal currentst = decimal.Zero; //currentst = commonFunctions.ToDecimal(objt_Stock.Stock.ToString()) + commonFunctions.ToDecimal(det.stock.ToString()); currentst = objt_Stock.Stock.Value; if (det.triggerVal == 1) { currentst += det.stock.Value; } if (det.triggerVal == 2) { currentst -= det.stock.Value; } objt_Stock.Stock = currentst; new T_StockDL().SaveT_StockSP(objt_Stock, 3, 1); } } catch (Exception ex) { commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); throw ex; } }
private void FindExisitingTransfer(string ReqNo) { try { if (T_adjustment_headDL.ExistingT_adjustment_head(ReqNo.Trim())) { formMode = 3; //clear datagrid dtx.Clear(); dataGridView1.Refresh(); //clear error fields errorProvider1.Clear(); t_adjustment_head cat = new t_adjustment_head(); cat.adju_no = ReqNo.Trim(); T_adjustment_headDL dl = new T_adjustment_headDL(); cat = dl.Selectt_adjustment_head(cat); //set the process message and mode to edit mode if (cat.process == false) { lbl_processes.Visible = false; performButtons(xEnums.PerformanceType.Edit); } else { lbl_processes.Visible = true; } //load and disable the data fields //txt_destinationLocId.Text = cat.destinationLocId.Trim(); //txt_sourceLocId.Text = cat.sourceLocId.Trim(); //txt_supplierId.Text = cat.supplierId.Trim(); txt_remarks.Text = cat.remarks; //dte_date.Value = cat.process_date.Value; textareaFunctions(false); t_adjustment_details req = new t_adjustment_details(); req.adju_no = ReqNo.Trim(); T_adjustment_detailDL tdl = new T_adjustment_detailDL(); List <t_adjustment_details> requests = new List <t_adjustment_details>(); requests = tdl.SelectT_adjustment_detailMulti(req); foreach (t_adjustment_details det in requests) { commonFunctions.AddRow(dtx, det.item_code, findExisting.FindExisitingStock(det.item_code).Trim(), det.cost.ToString(), det.cost.ToString(), det.physical_quantity.ToString(), det.variance.ToString()); } txt_net.Text = commonFunctions.GetGrossAmount(dataGridView1).ToString(); txt_grossAmount.Text = commonFunctions.GetGrossAmount(dataGridView1).ToString(); txt_noOfPeaces.Text = commonFunctions.GetNoofPices(dataGridView1).ToString(); txt_noOfItems.Text = commonFunctions.GetNoofItems(dataGridView1).ToString(); } else { if (formMode != 1) { errorProvider1.SetError(txt_no, "Adjutmnt Number you have entered does not exists in the system."); } } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error", 1); } }
private void performButtons(xEnums.PerformanceType xenum) { try { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_no.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["POFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["POSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["POField" + m + ""].ToString(); } frmU_Search find = new frmU_Search(strSQL, strSearchField, this); find.ShowDialog(this); } break; case xEnums.PerformanceType.New: FunctionButtonStatus(xEnums.PerformanceType.New); formMode = 1; txt_no.Text = commonFunctions.GetSerial(formID.Trim()); txt_no.Focus(); txt_sourceLocId.Text = commonFunctions.GlobalLocation; txt_locationId_name.Text = findExisting.FindExisitingLoca(txt_sourceLocId.Text.Trim()); errorProvider1.Clear(); lbl_processes.Visible = false; break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; //txt_VehicleID.Enabled = false; //txt_VehicleNo.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: errorProvider1.Clear(); if (formMode == 1) { if (!M_LocaDL.ExistingM_Loca(txt_sourceLocId.Text.Trim())) { errorProvider1.SetError(txt_sourceLocId, "Location does not exists on the system "); commonFunctions.SetMDIStatusMessage("Location does not exists on the system", 1); return; } if (commonFunctions.GetNoofItems(dataGridView1) <= 0) { errorProvider1.SetError(dataGridView1, "Please enter some items to the details grid"); commonFunctions.SetMDIStatusMessage("Please enter some items to the details grid", 1); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { try { using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope()) { //u_DBConnection.BeginTrans(); //save header data t_adjustment_head objt_adjustment_head = new t_adjustment_head(); objt_adjustment_head.adju_no = txt_no.Text.Trim(); objt_adjustment_head.location_id = commonFunctions.GlobalLocation; objt_adjustment_head.adjsment_date = dte_date.Value; objt_adjustment_head.remarks = txt_remarks.Text.Trim(); objt_adjustment_head.user_id = commonFunctions.Loginuser; objt_adjustment_head.batch_no = txt_batch_no.Text.Trim(); objt_adjustment_head.process = false; objt_adjustment_head.process_user = commonFunctions.Loginuser; objt_adjustment_head.process_date = DateTime.Now; objt_adjustment_head.triggerVal = 1; T_adjustment_headDL bal = new T_adjustment_headDL(); bal.Savet_adjustment_headSP(objt_adjustment_head, 1); //save details foreach (DataGridViewRow drow in dataGridView1.Rows) { if (drow.Cells["Product Code"].Value.ToString().Trim() != null) { //have to implement the logic. this is only saving the data to the system t_adjustment_details objt_adjustment_detail = new t_adjustment_details(); objt_adjustment_detail.adju_no = txt_no.Text.Trim(); objt_adjustment_detail.location_id = commonFunctions.GlobalLocation; objt_adjustment_detail.line_no = 1; objt_adjustment_detail.item_code = drow.Cells["Product Code"].Value.ToString(); objt_adjustment_detail.cost = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString()); objt_adjustment_detail.stock = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); objt_adjustment_detail.physical_quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); //txt_physical_quantity.Text.Trim(); objt_adjustment_detail.variance = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); if (rdo_add.Checked) { objt_adjustment_detail.triggerVal = 1; } if (rdo_reduce.Checked) { objt_adjustment_detail.triggerVal = 2; } T_adjustment_detailDL bal2 = new T_adjustment_detailDL(); bal2.Savet_adjustment_detailSP(objt_adjustment_detail, 1); } } //increment the serial commonFunctions.IncrementSerial(formID); transaction.Complete(); } //u_DBConnection.CommitTrans(); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim()); } catch (Exception ex) { // u_DBConnection.RollbackTrans(); LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on loading data", 1); } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { UpdateStock(); t_adjustment_head objt_trnsferNote = new t_adjustment_head(); objt_trnsferNote.adju_no = txt_no.Text.Trim(); T_adjustment_headDL balprocess = new T_adjustment_headDL(); objt_trnsferNote = balprocess.Selectt_adjustment_head(objt_trnsferNote); objt_trnsferNote.process = true; objt_trnsferNote.process_date = DateTime.Now; objt_trnsferNote.process_user = commonFunctions.Loginuser; balprocess.Savet_adjustment_headSP(objt_trnsferNote, 3); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim()); } //clear data in data grid dtx.Rows.Clear(); dataGridView1.Refresh(); //clear text fields textareaFunctions(true); FunctionButtonStatus(xEnums.PerformanceType.Save); //increment the serial txt_no.Text = commonFunctions.GetSerial(formID.Trim()); //txt_supplierId.Focus(); } } else if (formMode == 3) { t_adjustment_head cat = new t_adjustment_head(); cat.adju_no = txt_no.Text.Trim(); T_adjustment_headDL dl = new T_adjustment_headDL(); cat = dl.Selectt_adjustment_head(cat); if (cat.process == false) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { cat.location_id = txt_sourceLocId.Text.Trim(); cat.adjsment_date = dte_date.Value; cat.remarks = txt_remarks.Text.Trim(); cat.user_id = commonFunctions.Loginuser; cat.batch_no = txt_batch_no.Text.Trim(); new T_adjustment_headDL().Savet_adjustment_headSP(cat, 3); List <t_adjustment_details> detsx = new List <t_adjustment_details>(); t_adjustment_details detx = new t_adjustment_details(); detx.adju_no = cat.adju_no.Trim(); detsx = new T_adjustment_detailDL().SelectT_adjustment_detailMulti(detx); foreach (t_adjustment_details det in detsx) { new T_adjustment_detailDL().Savet_adjustment_detailSP(det, 4); } //save details foreach (DataGridViewRow drow in dataGridView1.Rows) { if (drow.Cells["Product Code"].Value.ToString().Trim() != null) { //have to implement the logic. this is only saving the data to the system t_adjustment_details objt_adjustment_detail = new t_adjustment_details(); objt_adjustment_detail.adju_no = txt_no.Text.Trim(); objt_adjustment_detail.location_id = txt_sourceLocId.Text.Trim(); objt_adjustment_detail.line_no = 1; objt_adjustment_detail.item_code = drow.Cells["Product Code"].Value.ToString(); objt_adjustment_detail.cost = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString()); objt_adjustment_detail.stock = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); objt_adjustment_detail.physical_quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); //txt_physical_quantity.Text.Trim(); objt_adjustment_detail.variance = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); if (rdo_add.Checked) { objt_adjustment_detail.triggerVal = 1; } if (rdo_reduce.Checked) { objt_adjustment_detail.triggerVal = 2; } T_adjustment_detailDL bal2 = new T_adjustment_detailDL(); bal2.Savet_adjustment_detailSP(objt_adjustment_detail, 1); } } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { cat.process = true; cat.process_date = DateTime.Now; cat.process_user = commonFunctions.Loginuser; new T_adjustment_headDL().Savet_adjustment_headSP(cat, 3); UpdateStock(); } UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim()); //clear data in data grid dtx.Rows.Clear(); dataGridView1.Refresh(); //clear text fields textareaFunctions(true); FunctionButtonStatus(xEnums.PerformanceType.Save); txt_no.Text = commonFunctions.GetSerial(formID.Trim()); txt_code.Focus(); } } else { errorProvider1.SetError(txt_no, "Adjustment Number you have entered already processed."); commonFunctions.SetMDIStatusMessage("Adjustment Number you have entered already processed", 1); } } break; case xEnums.PerformanceType.Cancel: txt_no.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); //clear text fields textareaFunctions(true); //clear Datagrid dtx.Clear(); dataGridView1.Refresh(); //txt_supplierId.Text = ""; //txt_remarks.Text = ""; lbl_processes.Visible = false; break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); } }