/*FunctionButtonStatus Was created by Asanga Chandrakumara on 12:18 PM 6/24/2015*/ /// <summary> /// THis function will enable and disable the button status as required /// </summary> /// <param name="typex">Enumaration to function type</param> public void FunctionButtonStatus(xEnums.PerformanceType typex) { u_UserRights_DL inspection = commonFunctions.GetUserRightObj("A0051", commonFunctions.Loginuser.Trim()); u_UserRights_DL dispatch = commonFunctions.GetUserRightObj("A0052", commonFunctions.Loginuser.Trim()); u_UserRights_DL handover = commonFunctions.GetUserRightObj("A0053", commonFunctions.Loginuser.Trim()); u_UserRights_DL confirmation = commonFunctions.GetUserRightObj("A0054", commonFunctions.Loginuser.Trim()); switch (typex) { case xEnums.PerformanceType.Default: btn_process.Enabled = inspection.boolAccess; btn_dispatchdo.Enabled = dispatch.boolAccess; btn_hanoverdo.Enabled = handover.boolAccess; btn_confirmdelivery.Enabled = confirmation.boolAccess; break; } //dataGridView1.Enabled = true; //txt_IDX.Enabled = true; }
private void performButtons(xEnums.PerformanceType xenum) { try { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_reqno.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["PurreqFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["PurreqField"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["VehicleField" + 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_reqno.Text = commonFunctions.GetSerial(formID.Trim()); txt_reqno.Focus(); 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 (T_purchaseRequisitionDL.ExistingT_purchaseRequisition(txt_reqno.Text.Trim())) { errorProvider1.SetError(txt_reqno, "Selected request No already exists on the system "); commonFunctions.SetMDIStatusMessage("Selected request No already exists on the system ", 1); return; } if (!M_LocaDL.ExistingM_Loca(txt_location.Text.Trim())) { errorProvider1.SetError(txt_location, "Selected location does not exists on the system "); commonFunctions.SetMDIStatusMessage("Selected location does not exists on the system", 1); return; } if (!M_SupplierDL.ExistingM_Supplier(txt_Suplier.Text.Trim())) { errorProvider1.SetError(txt_Suplier, "Selected supplier does not exists on the system "); commonFunctions.SetMDIStatusMessage("Selected supplier 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 (DateTime.Compare(dte_request.Value, dte_dilivary.Value) > -1) { errorProvider1.SetError(dte_dilivary, "Delivary date must be grater than request date"); commonFunctions.SetMDIStatusMessage("Delivary date must be grater than request date ", 1); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { using (TransactionScope transaction = new TransactionScope()) { //save header data t_purchaseRequisition objt_purchaseRequisition = new t_purchaseRequisition(); objt_purchaseRequisition.no = txt_reqno.Text.Trim(); objt_purchaseRequisition.date = dte_request.Value; objt_purchaseRequisition.deleveryDate = dte_dilivary.Value; objt_purchaseRequisition.remarks = txt_remark.Text.Trim(); objt_purchaseRequisition.processDate = DateTime.Now; objt_purchaseRequisition.processUser = ""; objt_purchaseRequisition.locationId = commonFunctions.GlobalLocation; objt_purchaseRequisition.supplierId = txt_Suplier.Text.Trim(); objt_purchaseRequisition.noOfItems = commonFunctions.ToDecimal(txt_items.Text.Trim()); objt_purchaseRequisition.noOfPeaces = commonFunctions.ToDecimal(txt_pices.Text.Trim()); objt_purchaseRequisition.grossAmount = commonFunctions.ToDecimal(txt_gross.Text.Trim()); objt_purchaseRequisition.isSaved = true; objt_purchaseRequisition.isProcessed = false; objt_purchaseRequisition.triggerVal = 1; T_purchaseRequisitionDL bal = new T_purchaseRequisitionDL(); bal.SaveT_purchaseRequisitionSP(objt_purchaseRequisition, 1); //save details foreach (DataGridViewRow drow in dataGridView1.Rows) { if (drow.Cells["Product Code"].Value.ToString().Trim() != null) { t_purchaseReq_detail objt_purchaseReq_detail = new t_purchaseReq_detail(); objt_purchaseReq_detail.purchaseReqNo = txt_reqno.Text.Trim(); objt_purchaseReq_detail.locationId = commonFunctions.GlobalLocation; objt_purchaseReq_detail.ReqDate = dte_request.Value; objt_purchaseReq_detail.deleveryDate = dte_dilivary.Value; objt_purchaseReq_detail.productId = drow.Cells["Product Code"].Value.ToString(); objt_purchaseReq_detail.description = drow.Cells["Product Name"].Value.ToString(); objt_purchaseReq_detail.quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); objt_purchaseReq_detail.costPrice = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString()); objt_purchaseReq_detail.amount = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString()); objt_purchaseReq_detail.release = 0; objt_purchaseReq_detail.r_value = 0; objt_purchaseReq_detail.triggerVal = 0; T_purchaseReq_detailDL bal2 = new T_purchaseReq_detailDL(); bal2.SaveT_purchaseReq_detailSP(objt_purchaseReq_detail, 1); } } //increment the serial commonFunctions.IncrementSerial(formID); transaction.Complete(); } UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim()); if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { t_purchaseRequisition objt_purchaseRequisitionxc = new t_purchaseRequisition(); objt_purchaseRequisitionxc.no = txt_reqno.Text.Trim(); T_purchaseRequisitionDL bal2 = new T_purchaseRequisitionDL(); objt_purchaseRequisitionxc = bal2.Selectt_purchaseRequisition(objt_purchaseRequisitionxc); objt_purchaseRequisitionxc.isProcessed = true; objt_purchaseRequisitionxc.processDate = DateTime.Now; objt_purchaseRequisitionxc.processUser = commonFunctions.Loginuser; bal2.SaveT_purchaseRequisitionSP(objt_purchaseRequisitionxc, 3); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim()); } //clear data in data grid dtx.Rows.Clear(); dataGridView1.Refresh(); //clear text fields txt_Suplier.Text = ""; txt_suppliername.Text = ""; txt_location.Text = ""; txt_locaname.Text = ""; txt_remark.Text = ""; txt_code.Text = ""; txt_cost.Text = "0.00"; txt_selling.Text = "0.00"; txt_qty.Text = "0.00"; txt_amt.Text = "0.00"; txt_reqno.Enabled = true; txt_Suplier.Enabled = true; txt_location.Enabled = true; txt_remark.Enabled = true; dataGridView1.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); //increment the serial txt_reqno.Text = commonFunctions.GetSerial(formID.Trim()); txt_location.Focus(); } } else if (formMode == 3) { t_purchaseRequisition cat = new t_purchaseRequisition(); cat.no = txt_reqno.Text.Trim(); T_purchaseRequisitionDL dl = new T_purchaseRequisitionDL(); cat = dl.Selectt_purchaseRequisition(cat); if (cat.isProcessed == false) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { t_purchaseRequisition objt_purchaseRequisitionxc = new t_purchaseRequisition(); objt_purchaseRequisitionxc.no = txt_reqno.Text.Trim(); T_purchaseRequisitionDL bal2 = new T_purchaseRequisitionDL(); objt_purchaseRequisitionxc = bal2.Selectt_purchaseRequisition(objt_purchaseRequisitionxc); objt_purchaseRequisitionxc.isProcessed = true; objt_purchaseRequisitionxc.processDate = DateTime.Now; objt_purchaseRequisitionxc.processUser = commonFunctions.Loginuser; bal2.SaveT_purchaseRequisitionSP(objt_purchaseRequisitionxc, 3); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim()); //clear data in data grid dtx.Rows.Clear(); dataGridView1.Refresh(); //clear text fields txt_Suplier.Text = ""; txt_suppliername.Text = ""; txt_location.Text = ""; txt_locaname.Text = ""; txt_remark.Text = ""; txt_reqno.Enabled = true; txt_Suplier.Enabled = true; txt_location.Enabled = true; txt_remark.Enabled = true; dataGridView1.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); //increment the serial txt_reqno.Text = commonFunctions.GetSerial(formID.Trim()); txt_location.Focus(); } } else { errorProvider1.SetError(txt_reqno, "Request Number you have entered already processed."); commonFunctions.SetMDIStatusMessage("Request Number you have entered already processed.", 1); } } break; case xEnums.PerformanceType.Cancel: txt_reqno.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); txt_Suplier.Enabled = true; txt_location.Enabled = true; txt_remark.Enabled = true; dataGridView1.Enabled = true; dtx.Clear(); dataGridView1.Refresh(); txt_Suplier.Text = ""; txt_location.Text = ""; txt_remark.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); } }
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); } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_bankcode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["BankFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["BankSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["BankField" + 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_bankcode.Focus(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 2; txt_name.Focus(); break; case xEnums.PerformanceType.Save: if (txt_bankcode.Text.Trim() == "") { errorProvider1.SetError(txt_bankcode, "Please enter a bank Code !"); return; } if (txt_name.Text.Trim() == "") { errorProvider1.SetError(txt_name, "Please enter a bank name !"); return; } if (formMode == 1) { if (M_BankDL.ExistingBank(txt_bankcode.Text.Trim())) { UserDefineMessages.ShowMsg("The bank code you have entered already exists!", UserDefineMessages.Msg_Warning); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Bank objbank = new M_Bank(); objbank.BANK_CODE = txt_bankcode.Text.Trim(); objbank.BANK_NAME = txt_name.Text.Trim().ToUpper(); M_BankDL bal = new M_BankDL(); bal.SaveBankSP(objbank, 1); GetData(); FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 2) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Bank objbank = new M_Bank(); objbank.BANK_CODE = txt_bankcode.Text.Trim(); objbank.BANK_NAME = txt_name.Text.Trim().ToUpper(); M_BankDL bal = new M_BankDL(); bal.SaveBankSP(objbank, 3); GetData(); FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: FunctionButtonStatus(xEnums.PerformanceType.Default); break; case xEnums.PerformanceType.Print: string reporttitle = "List of All Banks".ToUpper(); frm_reportViwer rpt = new frm_reportViwer(); rpt.MdiParent = MDI_SMartAnything.ActiveForm; rpt.FormHeadertext = reporttitle; ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); paramFields = commonFunctions.AddCrystalParams(reporttitle, commonFunctions.Loginuser); rpt_banks rptBank = new rpt_banks(); M_BankDL bankdlx = new M_BankDL(); rptBank.SetDataSource(bankdlx.SelectAllBanks()); rpt.RepViewer.ParameterFieldInfo = paramFields; rpt.RepViewer.ReportSource = rptBank; rpt.RepViewer.Refresh(); rpt.Show(); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_VehicleID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["VehicleFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["VehicleSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["VehicleField" + 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_VehicleID.Focus(); errorProvider1.Clear(); 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 (txt_VehicleNo.Text.Trim() == "") { errorProvider1.SetError(txt_VehicleNo, "Please enter a vehicle number !"); return; } if (txt_VehicleID.Text.Trim() == "") { errorProvider1.SetError(txt_VehicleID, "Please enter a vehicle ID !"); return; } if (incomingvehicle.Trim().ToUpper() != txt_VehicleNo.Text.Trim()) { if (M_VehicleDL.ExistingM_VehicleNo(txt_VehicleNo.Text.Trim())) { errorProvider1.SetError(txt_VehicleNo, "The vehicle number you have entered already exists!"); return; } } if (formMode == 1) { if (M_VehicleDL.ExistingM_Vehicle(txt_VehicleID.Text.Trim())) { errorProvider1.SetError(txt_VehicleID, "The vehicle code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Vehicles objm_Vehicle = new M_Vehicles(); objm_Vehicle.VehicleID = txt_VehicleID.Text.Trim(); objm_Vehicle.VehicleNo = txt_VehicleNo.Text.Trim(); objm_Vehicle.CompCode = commonFunctions.GlobalCompany; //txt_CompCode.Text.Trim(); objm_Vehicle.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Vehicle.Make = txt_Make.Text.Trim(); objm_Vehicle.Model = txt_Model.Text.Trim(); objm_Vehicle.Driver = txt_Driver.Text.Trim(); objm_Vehicle.Milage = txt_Milage.Text.Trim(); objm_Vehicle.FuelEfficiency = commonFunctions.ToDecimal(txt_FuelEfficiency.Text.Trim()); objm_Vehicle.Status = txt_Status.Text.Trim(); objm_Vehicle.Route = txt_Route.Text.Trim(); objm_Vehicle.Userx = commonFunctions.Loginuser; //txt_Userx.Text.Trim(); objm_Vehicle.Datex = DateTime.Now; //txt_Datex.Text.Trim(); M_VehicleDL bal = new M_VehicleDL(); bal.SaveM_VehicleSP(objm_Vehicle, 1); GetData(); txt_VehicleID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Vehicles objm_Vehicle = new M_Vehicles(); objm_Vehicle.VehicleID = txt_VehicleID.Text.Trim(); objm_Vehicle.VehicleNo = txt_VehicleNo.Text.Trim(); objm_Vehicle.CompCode = commonFunctions.GlobalCompany; //txt_CompCode.Text.Trim(); objm_Vehicle.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Vehicle.Make = txt_Make.Text.Trim(); objm_Vehicle.Model = txt_Model.Text.Trim(); objm_Vehicle.Driver = txt_Driver.Text.Trim(); objm_Vehicle.Milage = txt_Milage.Text.Trim(); objm_Vehicle.FuelEfficiency = commonFunctions.ToDecimal(txt_FuelEfficiency.Text.Trim()); objm_Vehicle.Status = txt_Status.Text.Trim(); objm_Vehicle.Route = txt_Route.Text.Trim(); objm_Vehicle.Userx = commonFunctions.Loginuser; //txt_Userx.Text.Trim(); objm_Vehicle.Datex = DateTime.Now; //txt_Datex.Text.Trim(); M_VehicleDL bal = new M_VehicleDL(); bal.SaveM_VehicleSP(objm_Vehicle, 3); GetData(); txt_VehicleID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_VehicleID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_SalesmanID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["SalesmanFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["SalesmanSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["SalesmanField" + m + ""].ToString(); } frmU_Search find = new frmU_Search(strSQL, strSearchField, this); find.ShowDialog(this); } break; case xEnums.PerformanceType.New: FunctionButtonStatus(xEnums.PerformanceType.New); //txt_IDX.Text = commonFunctions.GetSerial("A0009"); formMode = 1; txt_SalesmanID.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_SalesmanID.Enabled = false; txt_SalesmanName.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: errorProvider1.Clear(); if (txt_SalesmanID.Text.Trim().ToUpper() == "ADMIN") { errorProvider1.SetError(txt_SalesmanID, "This user is the system administrator. you cannot change the details."); commonFunctions.SetMDIStatusMessage("This user is the system administrator. you cannot change the details.", 1); return; } if (txt_SalesmanID.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanID, "User code cannot be a null value."); commonFunctions.SetMDIStatusMessage("User code cannot be a null value.", 1); return; } if (txt_SalesmanID.Text.Trim().Length < 5) { errorProvider1.SetError(txt_SalesmanID, "User code must be more than 6 charactors."); commonFunctions.SetMDIStatusMessage("User code must be more than 6 charactors", 1); return; } if (txt_SalesmanName.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanName, "User name cannot be a null value."); commonFunctions.SetMDIStatusMessage("User name cannot be a null value.", 1); return; } if (txtPw.Text == "") { errorProvider1.SetError(txtPw, "Password cannot be a null value."); commonFunctions.SetMDIStatusMessage("Password cannot be a null value.", 1); return; } if (txtPw.Text != txtRePw.Text) { errorProvider1.SetError(txtPw, "Password and the confirmation password must be same"); commonFunctions.SetMDIStatusMessage("Password and the confirmation password must be same.", 1); return; } if (!U_UserRolexDL.ExistingU_UserRole(txtusergroup.Text.Trim())) { errorProvider1.SetError(txtusergroup, "User group already exists."); commonFunctions.SetMDIStatusMessage("User group already exists.", 1); return; } if (txt_SalesmanName.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanName, "Please enter a employee name !"); commonFunctions.SetMDIStatusMessage("Please enter a employee name.", 1); return; } if (txt_SalesmanID.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanID, "Please enter a employee name !"); commonFunctions.SetMDIStatusMessage("Please enter a employee name.", 1); return; } if (formMode == 1) { if (U_UserxDL.ExistingU_User(txt_SalesmanID.Text.Trim())) { errorProvider1.SetError(txt_SalesmanID, "User code already exists."); commonFunctions.SetMDIStatusMessage("User code already exists.", 1); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { u_Userxcc obju_User = new u_Userxcc(); obju_User.userId = txt_SalesmanID.Text.Trim(); obju_User.userName = txt_SalesmanName.Text.Trim(); obju_User.password = commonFunctions.CreateCheckPassword(true, txtPw.Text.Trim()); obju_User.roleId = txtusergroup.Text.Trim(); obju_User.userCreated = commonFunctions.Loginuser; obju_User.dateCreated = DateTime.Now; obju_User.userModified = ""; obju_User.dateModified = DateTime.Now; obju_User.isActive = 1; obju_User.Type = txt_paymeth.Text.Trim().ToUpper(); obju_User.Compcode = commonFunctions.GlobalCompany; obju_User.Locacode = commonFunctions.GlobalLocation; obju_User.TP = txt_TP.Text.Trim(); obju_User.Fax = txt_Fax.Text.Trim(); obju_User.Email = txt_Email.Text.Trim(); obju_User.Address1 = txt_Address1.Text.Trim(); obju_User.Address2 = txt_Address2.Text.Trim(); obju_User.Address3 = txt_Address3.Text.Trim(); obju_User.ContactPerson = txt_ContactPerson.Text.Trim(); obju_User.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); obju_User.CurrentStatus = "Active"; obju_User.Gradex = "Good"; obju_User.NICNo = txt_nic.Text.Trim(); new U_UserxDL().Saveu_UserSP(obju_User, 1); GetData(); txt_SalesmanID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { u_Userxcc obju_User = new u_Userxcc(); obju_User.userId = txt_SalesmanID.Text.Trim(); obju_User = new U_UserxDL().Selectu_User(obju_User); obju_User.userId = txt_SalesmanID.Text.Trim(); obju_User.userName = txt_SalesmanName.Text.Trim(); obju_User.password = commonFunctions.CreateCheckPassword(true, txtPw.Text.Trim()); obju_User.roleId = txtusergroup.Text.Trim(); obju_User.userCreated = commonFunctions.Loginuser; obju_User.dateCreated = DateTime.Now; obju_User.userModified = ""; obju_User.dateModified = DateTime.Now; obju_User.isActive = 1; obju_User.Type = txt_paymeth.Text.Trim().ToUpper(); obju_User.Compcode = commonFunctions.GlobalCompany; obju_User.Locacode = commonFunctions.GlobalLocation; obju_User.TP = txt_TP.Text.Trim(); obju_User.Fax = txt_Fax.Text.Trim(); obju_User.Email = txt_Email.Text.Trim(); obju_User.Address1 = txt_Address1.Text.Trim(); obju_User.Address2 = txt_Address2.Text.Trim(); obju_User.Address3 = txt_Address3.Text.Trim(); obju_User.ContactPerson = txt_ContactPerson.Text.Trim(); obju_User.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); obju_User.CurrentStatus = "Active"; obju_User.Gradex = "Good"; obju_User.NICNo = txt_nic.Text.Trim(); new U_UserxDL().Saveu_UserSP(obju_User, 3); GetData(); txt_SalesmanID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_SalesmanID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_AreaCode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["AreaFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["AreaSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["AreaField" + 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_AreaCode.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_AreaCode.Enabled = false; txt_Descri.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: try { if (txt_AreaCode.Text.Trim() == "") { errorProvider1.SetError(txt_AreaCode, "Please enter a area Code !"); return; } if (txt_Descri.Text.Trim() == "") { errorProvider1.SetError(txt_Descri, "Please enter a area name !"); return; } if (formMode == 1) { if (M_AreaDL.ExistingM_Area(txt_AreaCode.Text.Trim())) { errorProvider1.SetError(txt_AreaCode, "The area code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Area objm_Area = new M_Area(); objm_Area.AreaCode = txt_AreaCode.Text.Trim(); objm_Area.Compcode = commonFunctions.GlobalCompany; // txt_Compcode.Text.Trim(); objm_Area.Locacode = commonFunctions.GlobalLocation; // txt_Locacode.Text.Trim(); objm_Area.Descri = txt_Descri.Text.Trim(); objm_Area.Datex = DateTime.Now; //txt_Datex.Text.Trim(); objm_Area.Userx = commonFunctions.Loginuser; // txt_Userx.Text.Trim(); M_AreaDL bal = new M_AreaDL(); bal.SaveM_AreaSP(objm_Area, 1); GetData(); txt_AreaCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim()); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Area objm_Area = new M_Area(); objm_Area.AreaCode = txt_AreaCode.Text.Trim(); objm_Area.Compcode = commonFunctions.GlobalCompany; // txt_Compcode.Text.Trim(); objm_Area.Locacode = commonFunctions.GlobalLocation; // txt_Locacode.Text.Trim(); objm_Area.Descri = txt_Descri.Text.Trim(); objm_Area.Datex = DateTime.Now; //txt_Datex.Text.Trim(); objm_Area.Userx = commonFunctions.Loginuser; // txt_Userx.Text.Trim(); M_AreaDL bal = new M_AreaDL(); bal.SaveM_AreaSP(objm_Area, 3); GetData(); txt_AreaCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_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); } break; case xEnums.PerformanceType.Cancel: txt_AreaCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: break; case xEnums.PerformanceType.New: FunctionButtonStatus(xEnums.PerformanceType.New); //txt_IDX.Text = commonFunctions.GetSerial("A0009"); formMode = 1; //txt_subcat_name.Text = ""; //txt_subcat.Text = ""; //txt_suppliername.Text = ""; //txt_categoryName.Text = ""; txt_UnitPrice.Text = "0.00"; txt_CostPrice.Text = "0.00"; txt_SKU.Text = ""; txt_MfctCode.Text = ""; txt_ModelNO.Text = ""; txt_SerialNo.Text = ""; txt_SellingPrice.Text = "0.00"; txt_IDX.Text = ""; txt_PartName.Text = ""; txt_IDX.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_IDX.Enabled = false; txt_PartName.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: if (txt_IDX.Text.Trim() == "") { errorProvider1.SetError(txt_IDX, "Please enter a product code !"); return; } if (txt_PartName.Text.Trim() == "") { errorProvider1.SetError(txt_PartName, "Please enter a part name !"); return; } if (formMode == 1) { if (M_ProductPartDL.ExistingM_ProductPart(txt_IDX.Text.Trim())) { errorProvider1.SetError(txt_IDX, "The part code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { using (var scope = new System.Transactions.TransactionScope()) { //adding the product M_ProductParts objm_ProductPart = new M_ProductParts(); objm_ProductPart.IDX = txt_IDX.Text.Trim(); objm_ProductPart.PartNo = txt_PartNo.Text.Trim(); objm_ProductPart.PartName = txt_PartName.Text.Trim(); objm_ProductPart.ModelNO = txt_ModelNO.Text.Trim(); objm_ProductPart.SerialNo = txt_SerialNo.Text.Trim(); objm_ProductPart.SKU = txt_SKU.Text.Trim(); objm_ProductPart.SuppCode = "";// txt_SuppCode.Text.Trim(); objm_ProductPart.MfctCode = txt_MfctCode.Text.Trim(); objm_ProductPart.UnitOfMeasure = txt_UnitOfMeasure.Text.Trim(); objm_ProductPart.Color = txt_Color.Text.Trim(); objm_ProductPart.Brand = txt_SKU.Text.Trim(); objm_ProductPart.Capacity = ""; objm_ProductPart.UnitPrice = Convert.ToDecimal(txt_UnitPrice.Text.Trim()); objm_ProductPart.SellingPrice = Convert.ToDecimal(txt_SellingPrice.Text.Trim()); objm_ProductPart.CostPrice = Convert.ToDecimal(txt_CostPrice.Text.Trim()); objm_ProductPart.AvgPrice = Convert.ToDecimal(txt_CostPrice.Text.Trim()); objm_ProductPart.PackSize = 0; objm_ProductPart.ReOrderLevel = 0; objm_ProductPart.MinQty = 10; objm_ProductPart.EOQty = 60; objm_ProductPart.ReOrderQty = 50; objm_ProductPart.CreateUser = commonFunctions.Loginuser; objm_ProductPart.CreateDate = DateTime.Now; objm_ProductPart.ModifyUser = commonFunctions.Loginuser; objm_ProductPart.ModifyDate = DateTime.Now; new M_ProductPartDL().Savem_ProductPartSP(objm_ProductPart, 1); //commonFunctions.IncrementSerial("A0009"); scope.Complete(); } GetData(); txt_IDX.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { using (var scope = new System.Transactions.TransactionScope()) { M_ProductParts objm_ProductPart = new M_ProductParts(); objm_ProductPart.IDX = txt_IDX.Text.Trim(); objm_ProductPart.PartNo = txt_PartNo.Text.Trim(); objm_ProductPart = new M_ProductPartDL().Selectm_ProductPart(objm_ProductPart); objm_ProductPart.PartName = txt_PartName.Text.Trim(); objm_ProductPart.ModelNO = txt_ModelNO.Text.Trim(); objm_ProductPart.SerialNo = txt_SerialNo.Text.Trim(); objm_ProductPart.SKU = txt_SKU.Text.Trim(); objm_ProductPart.SuppCode = "";// txt_SuppCode.Text.Trim(); objm_ProductPart.MfctCode = txt_MfctCode.Text.Trim(); objm_ProductPart.UnitOfMeasure = txt_UnitOfMeasure.Text.Trim(); objm_ProductPart.Color = txt_Color.Text.Trim(); objm_ProductPart.Brand = txt_SKU.Text.Trim(); objm_ProductPart.Capacity = ""; objm_ProductPart.UnitPrice = Convert.ToDecimal(txt_UnitPrice.Text.Trim()); objm_ProductPart.SellingPrice = Convert.ToDecimal(txt_SellingPrice.Text.Trim()); objm_ProductPart.CostPrice = Convert.ToDecimal(txt_CostPrice.Text.Trim()); objm_ProductPart.AvgPrice = Convert.ToDecimal(txt_CostPrice.Text.Trim()); objm_ProductPart.PackSize = 0; objm_ProductPart.ReOrderLevel = 0; objm_ProductPart.MinQty = 10; objm_ProductPart.EOQty = 60; objm_ProductPart.ReOrderQty = 50; objm_ProductPart.ModifyUser = commonFunctions.Loginuser; objm_ProductPart.ModifyDate = DateTime.Now; new M_ProductPartDL().Savem_ProductPartSP(objm_ProductPart, 1); scope.Complete(); } } GetData(); txt_IDX.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } break; case xEnums.PerformanceType.Cancel: txt_IDX.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_comcode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["BankFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["BankSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["BankField" + 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_comcode.Focus(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_name.Focus(); break; case xEnums.PerformanceType.Save: try { if (formMode == 1) { if (M_CompanyDL.ExistingBank(txt_comcode.Text.Trim())) { UserDefineMessages.ShowMsg("The company code you have entered already exists!", UserDefineMessages.Msg_Warning); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Company objbank = new M_Company(); objbank.CompCode = txt_comcode.Text.Trim(); objbank.Descr = txt_name.Text.Trim().ToUpper(); objbank.Add1 = txt_add1.Text.Trim(); objbank.Add2 = txt_add2.Text.Trim(); objbank.Add3 = txt_add3.Text.Trim(); objbank.Datex = DateTime.Now; objbank.Emailx = txt_email.Text.Trim(); objbank.Fax = txt_fax.Text.Trim(); objbank.Tpno = txt_tp.Text.Trim(); objbank.Userx = commonFunctions.Loginuser; M_CompanyDL bal = new M_CompanyDL(); bal.SaveBankSP(objbank, 1); GetData(); FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Company objbank = new M_Company(); objbank.CompCode = txt_comcode.Text.Trim(); objbank.Descr = txt_name.Text.Trim().ToUpper(); objbank.Add1 = txt_add1.Text.Trim(); objbank.Add2 = txt_add2.Text.Trim(); objbank.Add3 = txt_add3.Text.Trim(); objbank.Datex = DateTime.Now; objbank.Emailx = txt_email.Text.Trim(); objbank.Fax = txt_fax.Text.Trim(); objbank.Tpno = txt_tp.Text.Trim(); objbank.Userx = commonFunctions.Loginuser; M_CompanyDL bal = new M_CompanyDL(); bal.SaveBankSP(objbank, 3); GetData(); FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on loading data", 1); } break; case xEnums.PerformanceType.Cancel: FunctionButtonStatus(xEnums.PerformanceType.Default); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_ID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["AreaFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["AreaSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["AreaField" + 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_ID.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_ID.Enabled = false; txt_Reason.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: try { if (txt_ID.Text.Trim() == "") { errorProvider1.SetError(txt_ID, "Please enter a credit note code !"); return; } if (txt_Reason.Text.Trim() == "") { errorProvider1.SetError(txt_Reason, "Please enter a subcategory name !"); return; } if (formMode == 1) { if (M_CNReasonDL.ExistingM_CNReason(txt_ID.Text.Trim())) { errorProvider1.SetError(txt_ID, "The credit note reason you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_CNReason objm_CNReason = new M_CNReason(); objm_CNReason.ID = txt_ID.Text.Trim(); objm_CNReason.Reason = txt_Reason.Text.Trim(); objm_CNReason.NeedToUpdateStock = Chk_NeedToUpdateStock.Checked; objm_CNReason.StockType = comboBox1.Text.Trim(); objm_CNReason.UserCode = commonFunctions.Loginuser; objm_CNReason.Datex = DateTime.Now; new M_CNReasonDL().Savem_CNReasonSP(objm_CNReason, 1); GetData(); txt_ID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_CNReason objm_CNReason = new M_CNReason(); objm_CNReason.ID = txt_ID.Text.Trim(); objm_CNReason.Reason = txt_Reason.Text.Trim(); objm_CNReason.NeedToUpdateStock = Chk_NeedToUpdateStock.Checked; objm_CNReason.StockType = comboBox1.Text.Trim(); objm_CNReason.UserCode = commonFunctions.Loginuser; objm_CNReason.Datex = DateTime.Now; new M_CNReasonDL().Savem_CNReasonSP(objm_CNReason, 3); GetData(); txt_ID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); } break; case xEnums.PerformanceType.Cancel: txt_ID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_Routecode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["RouteFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["RouteSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["RouteField" + 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_Routecode.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_Routecode.Enabled = false; txt_Descr.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: errorProvider1.Clear(); if (txt_Descr.Text.Trim() == "") { errorProvider1.SetError(txt_Descr, "Please enter a route name !"); return; } if (txt_Routecode.Text.Trim() == "") { errorProvider1.SetError(txt_Routecode, "Please enter a route code !"); return; } if (formMode == 1) { if (M_RouteDL.ExistingM_Route(txt_Routecode.Text.Trim())) { errorProvider1.SetError(txt_Routecode, "The route code you have entered already exists!"); return; } if (!M_AreaDL.ExistingM_Area(txt_AreaCode.Text.Trim())) { errorProvider1.SetError(txt_AreaCode, "The area code you have entered not exists!"); return; } if (!M_TerritoryDL.ExistingM_Territory(txt_TerritoryCode.Text.Trim())) { errorProvider1.SetError(txt_TerritoryCode, "The territory code you have entered not exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Route objm_Route = new M_Route(); objm_Route.Routecode = txt_Routecode.Text.Trim(); objm_Route.Compcode = commonFunctions.GlobalCompany; //txt_Compcode.Text.Trim(); objm_Route.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Route.TerritoryCode = txt_TerritoryCode.Text.Trim(); objm_Route.AreaCode = txt_AreaCode.Text.Trim(); objm_Route.Descr = txt_Descr.Text.Trim(); objm_Route.Datex = DateTime.Now; objm_Route.Userx = commonFunctions.Loginuser; M_RouteDL bal = new M_RouteDL(); bal.SaveM_RouteSP(objm_Route, 1); GetData(); txt_TerritoryCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Route objm_Route = new M_Route(); objm_Route.Routecode = txt_Routecode.Text.Trim(); objm_Route.Compcode = commonFunctions.GlobalCompany; //txt_Compcode.Text.Trim(); objm_Route.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Route.TerritoryCode = txt_TerritoryCode.Text.Trim(); objm_Route.AreaCode = txt_AreaCode.Text.Trim(); objm_Route.Descr = txt_Descr.Text.Trim(); objm_Route.Datex = DateTime.Now; objm_Route.Userx = commonFunctions.Loginuser; M_RouteDL bal = new M_RouteDL(); bal.SaveM_RouteSP(objm_Route, 3); GetData(); txt_TerritoryCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_TerritoryCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_SupID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["SupplierFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["SupplierSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["SupplierField" + m + ""].ToString(); } frmU_Search find = new frmU_Search(strSQL, strSearchField, this); find.ShowDialog(this); } break; case xEnums.PerformanceType.New: FunctionButtonStatus(xEnums.PerformanceType.New); //txt_IDX.Text = commonFunctions.GetSerial("A0009"); formMode = 1; txt_SupID.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_SupID.Enabled = false; txt_suppName.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: if (txt_suppName.Text.Trim() == "") { errorProvider1.SetError(txt_suppName, "Please enter a supplier name !"); return; } if (txt_SupID.Text.Trim() == "") { errorProvider1.SetError(txt_SupID, "Please enter a supplier code !"); commonFunctions.SetMDIStatusMessage("Please enter a supplier code.", 1); return; } if (formMode == 1) { if (M_SupplierDL.ExistingM_Supplier(txt_SupID.Text.Trim())) { errorProvider1.SetError(txt_SupID, "The supplier code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Suppliers objm_Supplier = new M_Suppliers(); objm_Supplier.SupID = txt_SupID.Text.Trim(); objm_Supplier.suppName = txt_suppName.Text.Trim(); objm_Supplier.CompCode = commonFunctions.GlobalCompany; objm_Supplier.Locacode = commonFunctions.GlobalLocation; objm_Supplier.TP = txt_TP.Text.Trim(); objm_Supplier.Fax = txt_Fax.Text.Trim(); objm_Supplier.Email = txt_Email.Text.Trim(); objm_Supplier.Address1 = txt_Address1.Text.Trim(); objm_Supplier.Address2 = txt_Address2.Text.Trim(); objm_Supplier.Address3 = txt_Address3.Text.Trim(); objm_Supplier.ContactPerson = txt_ContactPerson.Text.Trim(); objm_Supplier.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); objm_Supplier.CurrentStatus = ""; M_SupplierDL bal = new M_SupplierDL(); bal.SaveM_SupplierSP(objm_Supplier, 1); GetData(); txt_SupID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Suppliers objm_Supplier = new M_Suppliers(); objm_Supplier.SupID = txt_SupID.Text.Trim(); objm_Supplier.suppName = txt_suppName.Text.Trim(); objm_Supplier.CompCode = commonFunctions.GlobalCompany; objm_Supplier.Locacode = commonFunctions.GlobalLocation; objm_Supplier.TP = txt_TP.Text.Trim(); objm_Supplier.Fax = txt_Fax.Text.Trim(); objm_Supplier.Email = txt_Email.Text.Trim(); objm_Supplier.Address1 = txt_Address1.Text.Trim(); objm_Supplier.Address2 = txt_Address2.Text.Trim(); objm_Supplier.Address3 = txt_Address3.Text.Trim(); objm_Supplier.ContactPerson = txt_ContactPerson.Text.Trim(); objm_Supplier.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); objm_Supplier.CurrentStatus = ""; M_SupplierDL bal = new M_SupplierDL(); bal.SaveM_SupplierSP(objm_Supplier, 3); GetData(); txt_SupID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_SupID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Prnt, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { string reporttitle = "List of All suppliers".ToUpper(); frm_reportViwer rpt = new frm_reportViwer(); rpt.MdiParent = MDI_SMartAnything.ActiveForm; rpt.FormHeadertext = reporttitle; ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); paramFields = commonFunctions.AddCrystalParams(reporttitle, commonFunctions.Loginuser.ToUpper()); string str = "SELECT * FROM M_Suppliers"; rpt_m_suppliers rptBank = new rpt_m_suppliers(); rptBank.SetDataSource(commonFunctions.GetDatatable(str)); rpt.RepViewer.ParameterFieldInfo = paramFields; rpt.RepViewer.ReportSource = rptBank; rpt.RepViewer.Refresh(); rpt.Show(); } break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_AgentCode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["AgentFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["AgentSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["AgentField" + 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_AgentCode.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_AgentCode.Enabled = false; txt_Namex.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: errorProvider1.Clear(); try { if (txt_Namex.Text.Trim() == "") { errorProvider1.SetError(txt_Namex, "Please enter a agent name !"); return; } if (txt_AgentCode.Text.Trim() == "") { errorProvider1.SetError(txt_AgentCode, "Please enter a Agent Code !"); return; } if (formMode == 1) { if (M_AgentDL.ExistingM_Agent(txt_AgentCode.Text.Trim())) { errorProvider1.SetError(txt_AgentCode, "The agent code you have entered already exists!"); return; } if (!M_AreaDL.ExistingM_Area(txt_AreaCode.Text.Trim())) { errorProvider1.SetError(txt_AreaCode, "The area code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Agents objm_Agent = new M_Agents(); objm_Agent.AgentCode = txt_AgentCode.Text.Trim(); objm_Agent.Namex = txt_Namex.Text.Trim(); objm_Agent.Address1 = txt_Address1.Text.Trim(); objm_Agent.Address2 = txt_Address2.Text.Trim(); objm_Agent.Address3 = txt_Address3.Text.Trim(); objm_Agent.TPOffice = txt_TPOffice.Text.Trim(); objm_Agent.TPPersonal = txt_TPPersonal.Text.Trim(); objm_Agent.Fax = txt_Fax.Text.Trim(); objm_Agent.Email = txt_Email.Text.Trim(); objm_Agent.AccNo = txt_AccNo.Text.Trim(); objm_Agent.NICno = txt_NICno.Text.Trim(); objm_Agent.PassportNo = txt_PassportNo.Text.Trim(); objm_Agent.Datex = DateTime.Now; // txt_Datex.Text.Trim(); objm_Agent.userx = commonFunctions.Loginuser; // txt_userx.Text.Trim(); objm_Agent.TimeFrom = dte_from.Value; objm_Agent.TimeTo = dte_to.Value; objm_Agent.District = txt_AreaCode.Text; objm_Agent.Remarks = txt_remarks.Text; M_AgentDL bal = new M_AgentDL(); bal.SaveM_AgentSP(objm_Agent, 1); GetData(); txt_AgentCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Agents objm_Agent = new M_Agents(); objm_Agent.AgentCode = txt_AgentCode.Text.Trim(); objm_Agent = new M_AgentDL().Selectm_Agent(objm_Agent); objm_Agent.Namex = txt_Namex.Text.Trim(); objm_Agent.Address1 = txt_Address1.Text.Trim(); objm_Agent.Address2 = txt_Address2.Text.Trim(); objm_Agent.Address3 = txt_Address3.Text.Trim(); objm_Agent.TPOffice = txt_TPOffice.Text.Trim(); objm_Agent.TPPersonal = txt_TPPersonal.Text.Trim(); objm_Agent.Fax = txt_Fax.Text.Trim(); objm_Agent.Email = txt_Email.Text.Trim(); objm_Agent.AccNo = txt_AccNo.Text.Trim(); objm_Agent.NICno = txt_NICno.Text.Trim(); objm_Agent.PassportNo = txt_PassportNo.Text.Trim(); objm_Agent.Datex = DateTime.Now; // txt_Datex.Text.Trim(); objm_Agent.userx = commonFunctions.Loginuser; // txt_userx.Text.Trim(); objm_Agent.TimeFrom = dte_from.Value; objm_Agent.TimeTo = dte_to.Value; objm_Agent.District = txt_AreaCode.Text; objm_Agent.Remarks = txt_remarks.Text; M_AgentDL bal = new M_AgentDL(); bal.SaveM_AgentSP(objm_Agent, 3); GetData(); txt_AgentCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); } break; case xEnums.PerformanceType.Cancel: txt_AgentCode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_CusID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["BankFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["BankSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["BankField" + 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_subcat_name.Text = ""; txt_subcat.Text = ""; txt_cat_name.Text = ""; txt_cat.Text = ""; txt_salesman_name.Text = ""; txt_salesman.Text = ""; txt_Areaname.Text = ""; txt_AreaCode.Text = ""; txt_ApplyingDisc.Text = "0.00"; txt_MinDisc.Text = "0.00"; txt_MaxDisc.Text = "0.00"; txt_CreditPeriod.Text = "0.00"; txt_CreditLimit.Text = "0.00"; txt_CusID.Text = ""; txt_CustName.Text = ""; txt_cat.Text = ""; txt_subcat.Text = ""; dtx.Clear(); dataGridView2.Refresh(); txt_ContactPerson.Text = ""; txt_ContactPersonNo.Text = ""; txt_Fax.Text = ""; txt_TP.Text = ""; txt_Address3.Text = ""; txt_Email.Text = ""; txt_Address1.Text = ""; txt_Address2.Text = ""; txt_CusID.Focus(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_CusID.Enabled = false; txt_CustName.Focus(); break; case xEnums.PerformanceType.Save: try { if (!discountHandling()) { return; } if (txt_CusID.Text.Trim() == "") { errorProvider1.SetError(txt_CusID, "Please enter a customer code !"); return; } if (txt_CustName.Text.Trim() == "") { errorProvider1.SetError(txt_CustName, "Please enter a customer name !"); return; } if (formMode == 1) { if (M_CustomerDL.ExistingM_Customer(txt_CusID.Text.Trim())) { //UserDefineMessages.ShowMsg("The Customer code you have entered already exists!", UserDefineMessages.Msg_Warning); errorProvider1.SetError(txt_CusID, "The Customer code you have entered already exists!"); return; } if (!M_AreaDL.ExistingM_Area(txt_AreaCode.Text.Trim())) { errorProvider1.SetError(txt_AreaCode, "Area does not exists on the system "); return; } if (!U_UserxDL.ExistingU_User(txt_salesman.Text.Trim())) { errorProvider1.SetError(txt_salesman, "Salesman does not exists on the system "); return; } if (commonFunctions.GetNoofItemsIndexBase(dataGridView2) <= 0) { errorProvider1.SetError(dataGridView2, "Please asign some agents to this customer."); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Customers objm_Customer = new M_Customers(); objm_Customer.CusID = txt_CusID.Text.Trim(); objm_Customer.Compcode = commonFunctions.GlobalCompany; //txt_Compcode.Text.Trim(); objm_Customer.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Customer.CustName = txt_CustName.Text.Trim(); objm_Customer.TP = txt_TP.Text.Trim(); objm_Customer.Fax = txt_Fax.Text.Trim(); objm_Customer.Email = txt_Email.Text.Trim(); objm_Customer.Address1 = txt_Address1.Text.Trim(); objm_Customer.Address2 = txt_Address2.Text.Trim(); objm_Customer.Address3 = txt_Address3.Text.Trim(); objm_Customer.ContactPerson = txt_ContactPerson.Text.Trim(); objm_Customer.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); objm_Customer.CurrentStatus = "";// txt_CurrentStatus.Text.Trim(); objm_Customer.Gradex = txt_Gradex.Text.Trim(); objm_Customer.CreditLimit = commonFunctions.ToDecimal(txt_CreditLimit.Text.Trim()); objm_Customer.CreditPeriod = int.Parse(txt_CreditPeriod.Text.Trim()); objm_Customer.MaxDisc = commonFunctions.ToDecimal(txt_MaxDisc.Text.Trim()); objm_Customer.MinDisc = commonFunctions.ToDecimal(txt_MinDisc.Text.Trim()); objm_Customer.ApplyingDisc = commonFunctions.ToDecimal(txt_ApplyingDisc.Text.Trim()); objm_Customer.CusOpenBal = decimal.Zero; objm_Customer.customerOS = decimal.Zero; objm_Customer.CusCurBal = decimal.Zero; objm_Customer.pointsEarned = decimal.Zero; objm_Customer.controlAccountCode = ""; objm_Customer.customerAccountCode = ""; objm_Customer.GLUpdate = false; objm_Customer.triggerVal = 1; objm_Customer.Area = txt_AreaCode.Text.Trim(); objm_Customer.SalesMan = txt_salesman.Text; objm_Customer.cat = txt_cat.Text; objm_Customer.subcat = txt_subcat.Text; M_CustomerDL bal = new M_CustomerDL(); bal.SaveM_CustomerSP(objm_Customer, 1); foreach (DataGridViewRow drow in dataGridView2.Rows) { if (drow.Cells[0].Value.ToString().Trim() != null) { M_CushasAgents objm_CushasAgent = new M_CushasAgents(); objm_CushasAgent.AgentCode = drow.Cells[0].Value.ToString(); objm_CushasAgent.CustomerCode = txt_CusID.Text; objm_CushasAgent.Datex = DateTime.Now; objm_CushasAgent.userx = commonFunctions.Loginuser; new M_CushasAgentDL().Savem_CushasAgentSP(objm_CushasAgent, 1); } } GetData(); txt_CusID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Customers objm_Customer = new M_Customers(); objm_Customer.CusID = txt_CusID.Text.Trim(); objm_Customer = new M_CustomerDL().Selectm_Customer(objm_Customer); objm_Customer.Compcode = commonFunctions.GlobalCompany; //txt_Compcode.Text.Trim(); objm_Customer.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Customer.CustName = txt_CustName.Text.Trim(); objm_Customer.TP = txt_TP.Text.Trim(); objm_Customer.Fax = txt_Fax.Text.Trim(); objm_Customer.Email = txt_Email.Text.Trim(); objm_Customer.Address1 = txt_Address1.Text.Trim(); objm_Customer.Address2 = txt_Address2.Text.Trim(); objm_Customer.Address3 = txt_Address3.Text.Trim(); objm_Customer.ContactPerson = txt_ContactPerson.Text.Trim(); objm_Customer.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); objm_Customer.CurrentStatus = ""; // txt_CurrentStatus.Text.Trim(); objm_Customer.Gradex = txt_Gradex.Text.Trim(); objm_Customer.CreditLimit = commonFunctions.ToDecimal(txt_CreditLimit.Text.Trim()); objm_Customer.CreditPeriod = int.Parse(txt_CreditPeriod.Text.Trim()); objm_Customer.MaxDisc = commonFunctions.ToDecimal(txt_MaxDisc.Text.Trim()); objm_Customer.MinDisc = commonFunctions.ToDecimal(txt_MinDisc.Text.Trim()); objm_Customer.ApplyingDisc = commonFunctions.ToDecimal(txt_ApplyingDisc.Text.Trim()); objm_Customer.cat = txt_cat.Text; objm_Customer.subcat = txt_subcat.Text; objm_Customer.SalesMan = txt_salesman.Text; new M_CustomerDL().SaveM_CustomerSP(objm_Customer, 3); M_CushasAgents xx = new M_CushasAgents(); xx.CustomerCode = txt_CusID.Text.Trim(); List <M_CushasAgents> agents = new List <M_CushasAgents>(); agents = new M_CushasAgentDL().SelectM_CushasAgentMulti(xx); foreach (M_CushasAgents age in agents) { new M_CushasAgentDL().Savem_CushasAgentSP(age, 4); } foreach (DataGridViewRow drow in dataGridView2.Rows) { if (drow.Cells[0].Value.ToString().Trim() != null) { M_CushasAgents objm_CushasAgent = new M_CushasAgents(); objm_CushasAgent.AgentCode = drow.Cells[0].Value.ToString(); objm_CushasAgent.CustomerCode = txt_CusID.Text; objm_CushasAgent.Datex = DateTime.Now; objm_CushasAgent.userx = commonFunctions.Loginuser; new M_CushasAgentDL().Savem_CushasAgentSP(objm_CushasAgent, 1); } } GetData(); txt_CusID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on loading data", 1); } break; case xEnums.PerformanceType.Cancel: txt_CusID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); break; case xEnums.PerformanceType.Print: if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Prnt, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { string reporttitle = "List of All Customers".ToUpper(); frm_reportViwer rpt = new frm_reportViwer(); rpt.MdiParent = MDI_SMartAnything.ActiveForm; rpt.FormHeadertext = reporttitle; ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); paramFields = commonFunctions.AddCrystalParams(reporttitle, commonFunctions.Loginuser.ToUpper()); rpt_m_Customers rptBank = new rpt_m_Customers(); M_CustomerDL bankdlx = new M_CustomerDL(); rptBank.SetDataSource(bankdlx.SelectAllm_CustomerAll()); rpt.RepViewer.ParameterFieldInfo = paramFields; rpt.RepViewer.ReportSource = rptBank; rpt.RepViewer.Refresh(); rpt.Show(); } break; } }
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 (txt_sourceLocId.Text.Trim().ToUpper() == txt_destinationLocId.Text.Trim().ToUpper()) { errorProvider1.SetError(txt_destinationLocId, "Destination location cannot same as login location"); return; } 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 (!M_LocaDL.ExistingM_Loca(txt_destinationLocId.Text.Trim())) { errorProvider1.SetError(txt_destinationLocId, "Destination Location does not exists on the system "); commonFunctions.SetMDIStatusMessage("Destination 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_trnsferInNote objt_trnsferInNote = new t_trnsferInNote(); objt_trnsferInNote.transinNo = txt_no.Text.Trim(); objt_trnsferInNote.sourceLocId = commonFunctions.GlobalLocation; objt_trnsferInNote.date = dte_date.Value; objt_trnsferInNote.refNo = txt_refNo.Text.Trim(); objt_trnsferInNote.remarks = txt_remarks.Text.Trim(); objt_trnsferInNote.destinationLocId = txt_destinationLocId.Text.Trim(); objt_trnsferInNote.purchaseReqNo = txt_purchaseReqNo.Text.Trim(); objt_trnsferInNote.noOfItems = commonFunctions.ToDecimal(txt_noOfItems.Text.Trim()); objt_trnsferInNote.noOfPeaces = commonFunctions.ToDecimal(txt_noOfPeaces.Text.Trim()); objt_trnsferInNote.grossAmount = commonFunctions.ToDecimal(txt_grossAmount.Text.Trim()); objt_trnsferInNote.isProcessed = false; objt_trnsferInNote.processDate = DateTime.Now; objt_trnsferInNote.processUser = ""; objt_trnsferInNote.GLUpdate = false; objt_trnsferInNote.triggerVal = 1; T_trnsferInNoteDL bal = new T_trnsferInNoteDL(); bal.Savet_trnsferInNoteSP(objt_trnsferInNote, 1); //save details foreach (DataGridViewRow drow in dataGridView1.Rows) { if (drow.Cells["Product Code"].Value.ToString().Trim() != null) { t_transferIn_detail objt_transferIn_detail = new t_transferIn_detail(); objt_transferIn_detail.transinrNo = txt_no.Text.Trim(); objt_transferIn_detail.sourceLocId = commonFunctions.GlobalLocation; objt_transferIn_detail.destinationLocId = txt_destinationLocId.Text.Trim(); objt_transferIn_detail.transferDate = dte_date.Value; objt_transferIn_detail.stockCode = drow.Cells["Product Code"].Value.ToString(); objt_transferIn_detail.description = drow.Cells["Product Name"].Value.ToString(); objt_transferIn_detail.quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString()); objt_transferIn_detail.costPrice = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString()); objt_transferIn_detail.amount = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString()); objt_transferIn_detail.triggerVal = 1; T_transferIn_detailDL bal2 = new T_transferIn_detailDL(); bal2.Savet_transferIn_detailSP(objt_transferIn_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("Save Transactions", "Transfer In", ex.Message); LogFile.WriteErrorLog("Save Transactions", "Transfer Out", ex.Message); commonFunctions.SetMDIStatusMessage("Transfer Number you have entered already processed", 1); } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { UpdateStock(); t_trnsferInNote objt_trnsferNote = new t_trnsferInNote(); objt_trnsferNote.transinNo = txt_no.Text.Trim(); T_trnsferInNoteDL balprocess = new T_trnsferInNoteDL(); objt_trnsferNote = balprocess.Selectt_trnsferInNote(objt_trnsferNote); objt_trnsferNote.isProcessed = true; objt_trnsferNote.processDate = DateTime.Now; objt_trnsferNote.processUser = commonFunctions.Loginuser; balprocess.Savet_trnsferInNoteSP(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_trnsferInNote cat = new t_trnsferInNote(); cat.transinNo = txt_no.Text.Trim(); T_trnsferInNoteDL dl = new T_trnsferInNoteDL(); cat = dl.Selectt_trnsferInNote(cat); if (cat.isProcessed == false) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { UpdateStock(); t_trnsferInNote objt_trnsferNote = new t_trnsferInNote(); objt_trnsferNote.transinNo = txt_no.Text.Trim(); T_trnsferInNoteDL balprocess = new T_trnsferInNoteDL(); objt_trnsferNote = balprocess.Selectt_trnsferInNote(objt_trnsferNote); objt_trnsferNote.isProcessed = true; objt_trnsferNote.processDate = DateTime.Now; objt_trnsferNote.processUser = commonFunctions.Loginuser; balprocess.Savet_trnsferInNoteSP(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_refNo.Focus(); } } else { errorProvider1.SetError(txt_no, "Transfer IN 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(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on loading data", 1); } }
/*FunctionButtonStatus Was created by Asanga Chandrakumara on 12:18 PM 6/24/2015*/ /// <summary> /// THis function will enable and disable the button status as required /// </summary> /// <param name="typex">Enumaration to function type</param> public void FunctionButtonStatus(xEnums.PerformanceType typex) { u_UserRights objUserRight = new u_UserRights(); objUserRight.User = new u_User(); objUserRight.MenuTag = new u_MenuTag(); objUserRight.User.strUserID = Globals.g_strUser; objUserRight.MenuTag.strMenuID = formID.Trim(); u_UserRights_DL objURightDL = new u_UserRights_DL(); u_UserRights_DL dtAllMenuItems = objURightDL.GetUserRightsForOneMenu(objUserRight); switch (typex) { case xEnums.PerformanceType.Save: if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; btn_cancel.Enabled = false; btn_save.Enabled = false; btn_delete.Enabled = dtAllMenuItems.boolDelete; btn_edit.Enabled = false; btn_print.Enabled = dtAllMenuItems.boolPrint; //dataGridView1.Enabled = true; //txt_IDX.Enabled = true; } else { btn_cancel.Enabled = false; btn_save.Enabled = false; btn_new.Enabled = true; btn_delete.Enabled = dtAllMenuItems.boolDelete; btn_edit.Enabled = false; btn_print.Enabled = dtAllMenuItems.boolPrint; //dataGridView1.Enabled = true; //txt_IDX.Enabled = true; } break; case xEnums.PerformanceType.Delete: //when press the delete button if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; } else { btn_cancel.Enabled = false; btn_save.Enabled = false; btn_new.Enabled = true; btn_delete.Enabled = false; btn_edit.Enabled = false; btn_print.Enabled = false; } break; case xEnums.PerformanceType.Existing: //enter existing item to system if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; } else { btn_cancel.Enabled = true; btn_save.Enabled = false; btn_new.Enabled = false; btn_delete.Enabled = dtAllMenuItems.boolDelete; btn_edit.Enabled = false; btn_print.Enabled = dtAllMenuItems.boolPrint; } break; case xEnums.PerformanceType.Edit: //enter existing item to system and press edit if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; btn_cancel.Enabled = true; btn_save.Enabled = true; btn_new.Enabled = dtAllMenuItems.boolCreate; btn_delete.Enabled = dtAllMenuItems.boolDelete; btn_edit.Enabled = false; btn_print.Enabled = dtAllMenuItems.boolPrint; // dataGridView1.Enabled = false; //txt_IDX.Enabled = false; } else { btn_cancel.Enabled = true; btn_save.Enabled = true; btn_new.Enabled = false; btn_delete.Enabled = false; btn_edit.Enabled = false; btn_print.Enabled = false; //dataGridView1.Enabled = false; //txt_IDX.Enabled = false; } break; case xEnums.PerformanceType.Exit: break; case xEnums.PerformanceType.New: if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; dataGridView1.Enabled = false; //txt_IDX.Enabled = false; } else { btn_cancel.Enabled = true; btn_save.Enabled = true; btn_new.Enabled = false; btn_delete.Enabled = false; btn_edit.Enabled = false; btn_print.Enabled = false; //dataGridView1.Enabled = false; //txt_IDX.Enabled = false; } break; case xEnums.PerformanceType.Default: if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; btn_delete.Enabled = dtAllMenuItems.boolDelete; btn_edit.Enabled = false; btn_print.Enabled = dtAllMenuItems.boolPrint; btn_save.Enabled = false; btn_cancel.Enabled = false; //dataGridView1.Enabled = true; //txt_IDX.Enabled = true; } else { btn_cancel.Enabled = false; btn_save.Enabled = false; btn_new.Enabled = true; btn_delete.Enabled = dtAllMenuItems.boolDelete; btn_edit.Enabled = false; btn_print.Enabled = dtAllMenuItems.boolPrint; //dataGridView1.Enabled = true; //txt_IDX.Enabled = true; } break; case xEnums.PerformanceType.Cancel: if (dtAllMenuItems.boolCreate == false) { btn_new.Enabled = false; dataGridView1.Enabled = true; //txt_IDX.Enabled = true; } else { btn_cancel.Enabled = false; btn_save.Enabled = false; btn_new.Enabled = false; btn_delete.Enabled = false; btn_edit.Enabled = false; btn_print.Enabled = false; dataGridView1.Enabled = true; //txt_IDX.Enabled = true; } break; } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_Locacode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["BankFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["BankSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["BankField" + 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_Locacode.Focus(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_Locacode.Enabled = false; txt_Locaname.Focus(); break; case xEnums.PerformanceType.Save: if (formMode == 1) { if (M_LocaDL.ExistingM_Loca(txt_Locacode.Text.Trim())) { UserDefineMessages.ShowMsg("The location code you have entered already exists!", UserDefineMessages.Msg_Warning); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Loca objm_Loca = new M_Loca(); objm_Loca.Locacode = txt_Locacode.Text.Trim(); objm_Loca.Companycode = commonFunctions.GlobalCompany.Trim(); objm_Loca.StockCode = txt_Locacode.Text.Trim(); objm_Loca.Locaname = txt_Locaname.Text.Trim(); objm_Loca.Add1 = txt_Add1.Text.Trim(); objm_Loca.Add2 = txt_Add2.Text.Trim(); objm_Loca.Add3 = txt_Add3.Text.Trim(); objm_Loca.Tpno = txt_Tpno.Text.Trim(); objm_Loca.Fax = txt_Fax.Text.Trim(); objm_Loca.Emailx = txt_Emailx.Text.Trim(); objm_Loca.Userx = commonFunctions.Loginuser; objm_Loca.Datex = DateTime.Now; M_LocaDL bal = new M_LocaDL(); bal.SaveM_LocaSP(objm_Loca, 1); GetData(); txt_Locacode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Loca objm_Loca = new M_Loca(); objm_Loca.Locacode = txt_Locacode.Text.Trim(); objm_Loca.Companycode = commonFunctions.GlobalCompany.Trim(); objm_Loca.StockCode = txt_Locacode.Text.Trim(); objm_Loca.Locaname = txt_Locaname.Text.Trim(); objm_Loca.Add1 = txt_Add1.Text.Trim(); objm_Loca.Add2 = txt_Add2.Text.Trim(); objm_Loca.Add3 = txt_Add3.Text.Trim(); objm_Loca.Tpno = txt_Tpno.Text.Trim(); objm_Loca.Fax = txt_Fax.Text.Trim(); objm_Loca.Emailx = txt_Emailx.Text.Trim(); objm_Loca.Userx = commonFunctions.Loginuser; objm_Loca.Datex = DateTime.Now; M_LocaDL bal = new M_LocaDL(); bal.SaveM_LocaSP(objm_Loca, 3); GetData(); txt_Locacode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_Locacode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }