public t_staffUsage_detail Selectt_staffUsage_detail(t_staffUsage_detail objt_staffUsage_detail) { try { strquery = @"select * from t_staffUsage_detail where staffUsageNo = '" + objt_staffUsage_detail.staffUsageNo + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objt_staffUsage_detail.staffUsageNo = drType["staffUsageNo"].ToString(); objt_staffUsage_detail.locationId = drType["locationId"].ToString(); objt_staffUsage_detail.Date = DateTime.Parse(drType["Date"].ToString()); objt_staffUsage_detail.stockCode = drType["stockCode"].ToString(); objt_staffUsage_detail.description = drType["description"].ToString(); objt_staffUsage_detail.quantity = decimal.Parse(drType["quantity"].ToString()); objt_staffUsage_detail.costPrice = decimal.Parse(drType["costPrice"].ToString()); objt_staffUsage_detail.amount = decimal.Parse(drType["amount"].ToString()); objt_staffUsage_detail.triggerVal = int.Parse(drType["triggerVal"].ToString()); return(objt_staffUsage_detail); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// Saves a record to the t_staffUsage_detail table. /// </summary> public Boolean Savet_staffUsage_detailSP(t_staffUsage_detail t_staffUsage_detail, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "T_staffUsage_detailSave"; scom.Parameters.Add("@staffUsageNo", SqlDbType.VarChar, 20).Value = t_staffUsage_detail.staffUsageNo; scom.Parameters.Add("@locationId", SqlDbType.VarChar, 20).Value = t_staffUsage_detail.locationId; scom.Parameters.Add("@Date", SqlDbType.DateTime, 8).Value = t_staffUsage_detail.Date; scom.Parameters.Add("@stockCode", SqlDbType.VarChar, 20).Value = t_staffUsage_detail.stockCode; scom.Parameters.Add("@description", SqlDbType.VarChar, 150).Value = t_staffUsage_detail.description; scom.Parameters.Add("@quantity", SqlDbType.Decimal, 9).Value = t_staffUsage_detail.quantity; scom.Parameters.Add("@costPrice", SqlDbType.Decimal, 9).Value = t_staffUsage_detail.costPrice; scom.Parameters.Add("@amount", SqlDbType.Decimal, 9).Value = t_staffUsage_detail.amount; scom.Parameters.Add("@triggerVal", SqlDbType.Int, 4).Value = t_staffUsage_detail.triggerVal; scom.Parameters.Add("@InsMode", SqlDbType.Int).Value = formMode; // For insert scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0; u_DBConnection dbcon = new u_DBConnection(); retvalue = dbcon.RunQuery(scom); return(retvalue); } catch (Exception ex) { throw (ex); } }
public List <t_staffUsage_detail> SelectT_staffUsage_detailMulti(t_staffUsage_detail objt_staffUsage_detail2) { List <t_staffUsage_detail> retval = new List <t_staffUsage_detail>(); try { strquery = @"select * from t_staffUsage_detail where staffUsageNo = '" + objt_staffUsage_detail2.staffUsageNo + "'"; DataTable dtt_staffUsage_detail = u_DBConnection.ReturnDataTable(strquery, CommandType.Text); foreach (DataRow drType in dtt_staffUsage_detail.Rows) { if (drType != null) { t_staffUsage_detail objt_staffUsage_detail = new t_staffUsage_detail(); objt_staffUsage_detail.staffUsageNo = drType["staffUsageNo"].ToString(); objt_staffUsage_detail.locationId = drType["locationId"].ToString(); objt_staffUsage_detail.Date = DateTime.Parse(drType["Date"].ToString()); objt_staffUsage_detail.stockCode = drType["stockCode"].ToString(); objt_staffUsage_detail.description = drType["description"].ToString(); objt_staffUsage_detail.quantity = decimal.Parse(drType["quantity"].ToString()); objt_staffUsage_detail.costPrice = decimal.Parse(drType["costPrice"].ToString()); objt_staffUsage_detail.amount = decimal.Parse(drType["amount"].ToString()); objt_staffUsage_detail.triggerVal = int.Parse(drType["triggerVal"].ToString()); retval.Add(objt_staffUsage_detail); } } return(retval); } catch (Exception ex) { throw ex; } }
private void UpdateStock() { try { t_staffUsage_detail trans = new t_staffUsage_detail(); trans.staffUsageNo = txt_no.Text.Trim(); List <t_staffUsage_detail> Transins = new List <t_staffUsage_detail>(); Transins = new T_staffUsage_detailDL().SelectT_staffUsage_detailMulti(trans); foreach (t_staffUsage_detail det in Transins) { 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); decimal currentst = decimal.Zero; currentst = commonFunctions.ToDecimal(objt_Stock.Stock.ToString()) - commonFunctions.ToDecimal(det.quantity.ToString()); 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) { if (T_staffUsageDL.ExistingT_staffUsage(ReqNo.Trim())) { formMode = 3; //clear datagrid dtx.Clear(); dataGridView1.Refresh(); //clear error fields errorProvider1.Clear(); t_staffUsage cat = new t_staffUsage(); cat.no = ReqNo.Trim(); T_staffUsageDL dl = new T_staffUsageDL(); cat = dl.Selectt_staffUsage(cat); //set the process message and mode to edit mode if (cat.isProcessed == 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.locationId.Trim(); //txt_supplierId.Text = cat.supplierId.Trim(); txt_remarks.Text = cat.remarks; //dte_date.Value = cat.process_date.Value; textareaFunctions(false); t_staffUsage_detail req = new t_staffUsage_detail(); req.staffUsageNo = ReqNo.Trim(); T_staffUsage_detailDL tdl = new T_staffUsage_detailDL(); List <t_staffUsage_detail> requests = new List <t_staffUsage_detail>(); requests = tdl.SelectT_staffUsage_detailMulti(req); foreach (t_staffUsage_detail det in requests) { commonFunctions.AddRow(dtx, det.stockCode, findExisting.FindExisitingStock(det.stockCode).Trim(), det.costPrice.ToString(), det.costPrice.ToString(), det.quantity.ToString(), det.amount.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, "Wastage Number you have entered does not exists in the system."); } } }
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["StaffUSFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["StaffUSSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["StaffUSField" + 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 "); return; } if (commonFunctions.GetNoofItems(dataGridView1) <= 0) { errorProvider1.SetError(dataGridView1, "Please enter some items to the details grid"); 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_staffUsage objt_staffUsage = new t_staffUsage(); objt_staffUsage.no = txt_no.Text.Trim(); objt_staffUsage.locationId = commonFunctions.GlobalLocation; objt_staffUsage.date = dte_date.Value; objt_staffUsage.refNo = txt_refNo.Text.Trim(); objt_staffUsage.remarks = txt_remarks.Text.Trim(); objt_staffUsage.noOfItems = commonFunctions.ToDecimal(txt_noOfItems.Text.Trim()); objt_staffUsage.noOfPeaces = commonFunctions.ToDecimal(txt_noOfPeaces.Text.Trim()); objt_staffUsage.grossAmount = commonFunctions.ToDecimal(txt_grossAmount.Text.Trim()); objt_staffUsage.isSaved = true; objt_staffUsage.isProcessed = false; objt_staffUsage.processDate = DateTime.Now; objt_staffUsage.processUser = ""; objt_staffUsage.triggerVal = 1; objt_staffUsage.GLUpdate = false; T_staffUsageDL bal = new T_staffUsageDL(); bal.Savet_staffUsageSP(objt_staffUsage, 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_staffUsage_detail objt_staffUsage_detail = new t_staffUsage_detail(); objt_staffUsage_detail.staffUsageNo = txt_no.Text.Trim(); objt_staffUsage_detail.locationId = commonFunctions.GlobalLocation; objt_staffUsage_detail.Date = dte_date.Value; objt_staffUsage_detail.stockCode = drow.Cells["Product Code"].Value.ToString(); objt_staffUsage_detail.description = findExisting.FindExisitingProduct(drow.Cells["Product Code"].Value.ToString()); objt_staffUsage_detail.quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); objt_staffUsage_detail.costPrice = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString()); objt_staffUsage_detail.amount = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString()); objt_staffUsage_detail.triggerVal = 1; T_staffUsage_detailDL bal22 = new T_staffUsage_detailDL(); bal22.Savet_staffUsage_detailSP(objt_staffUsage_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) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { UpdateStock(); t_staffUsage objt_trnsferNote = new t_staffUsage(); objt_trnsferNote.no = txt_no.Text.Trim(); T_staffUsageDL balprocess = new T_staffUsageDL(); objt_trnsferNote = balprocess.Selectt_staffUsage(objt_trnsferNote); objt_trnsferNote.isProcessed = true; objt_trnsferNote.processDate = DateTime.Now; objt_trnsferNote.processUser = commonFunctions.Loginuser; balprocess.Savet_staffUsageSP(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_staffUsage cat = new t_staffUsage(); cat.no = txt_no.Text.Trim(); T_staffUsageDL dl = new T_staffUsageDL(); cat = dl.Selectt_staffUsage(cat); if (cat.isProcessed == false) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { UpdateStock(); t_staffUsage objt_trnsferNote = new t_staffUsage(); objt_trnsferNote.no = txt_no.Text.Trim(); T_staffUsageDL balprocess = new T_staffUsageDL(); objt_trnsferNote = balprocess.Selectt_staffUsage(objt_trnsferNote); objt_trnsferNote.isProcessed = true; objt_trnsferNote.processDate = DateTime.Now; objt_trnsferNote.processUser = commonFunctions.Loginuser; balprocess.Savet_staffUsageSP(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); txt_no.Text = commonFunctions.GetSerial(formID.Trim()); txt_code.Focus(); } } else { errorProvider1.SetError(txt_no, "Wastage number you have entered already processed."); } } 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("performButtons", "frm_purchaserequest", ex.Message.ToString()); throw ex; } }