/// <summary> /// Saves a record to the M_CushasAgents table. /// </summary> public Boolean Savem_CushasAgentSP(M_CushasAgents m_CushasAgent, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "M_CushasAgentsSave"; scom.Parameters.Add("@AgentCode", SqlDbType.VarChar, 20).Value = m_CushasAgent.AgentCode; scom.Parameters.Add("@CustomerCode", SqlDbType.VarChar, 20).Value = m_CushasAgent.CustomerCode; scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value = m_CushasAgent.Datex; scom.Parameters.Add("@userx", SqlDbType.VarChar, 20).Value = m_CushasAgent.userx; 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 <M_CushasAgents> SelectM_CushasAgentMulti(M_CushasAgents objm_CushasAgent2) { List <M_CushasAgents> retval = new List <M_CushasAgents>(); try { strquery = @"select * from M_CushasAgents where CustomerCode = '" + objm_CushasAgent2.CustomerCode + "'"; DataTable dtm_CushasAgent = u_DBConnection.ReturnDataTable(strquery, CommandType.Text); foreach (DataRow drType in dtm_CushasAgent.Rows) { if (drType != null) { M_CushasAgents objm_CushasAgent = new M_CushasAgents(); objm_CushasAgent.AgentCode = drType["AgentCode"].ToString(); objm_CushasAgent.CustomerCode = drType["CustomerCode"].ToString(); objm_CushasAgent.Datex = DateTime.Parse(drType["Datex"].ToString()); objm_CushasAgent.userx = drType["userx"].ToString(); retval.Add(objm_CushasAgent); } } return(retval); } catch (Exception ex) { throw ex; } }
private void SetValues(String sm_Customer) { try { M_CustomerDL objm_CustomerDL = new M_CustomerDL(); M_Customers objm_Customer = new M_Customers(); if (sm_Customer != "") { objm_Customer.CusID = sm_Customer; objm_Customer = objm_CustomerDL.Selectm_Customer(objm_Customer); if (objm_Customer != null) { txt_CusID.Text = objm_Customer.CusID.ToString(); //txt_Compcode.Text = objm_Customer.Compcode.ToString(); //txt_CusID.Text = objm_Customer.Locacode.ToString(); txt_CustName.Text = objm_Customer.CustName.ToString(); txt_TP.Text = objm_Customer.TP.ToString(); txt_Fax.Text = objm_Customer.Fax.ToString(); txt_Email.Text = objm_Customer.Email.ToString(); txt_Address1.Text = objm_Customer.Address1.ToString(); txt_Address2.Text = objm_Customer.Address2.ToString(); txt_Address3.Text = objm_Customer.Address3.ToString(); txt_ContactPerson.Text = objm_Customer.ContactPerson.ToString(); txt_ContactPersonNo.Text = objm_Customer.ContactPersonNo.ToString(); //txt_CurrentStatus.Text = objm_Customer.CurrentStatus.ToString(); txt_Gradex.Text = objm_Customer.Gradex.ToString(); txt_CreditLimit.Text = objm_Customer.CreditLimit.ToString(); txt_CreditPeriod.Text = objm_Customer.CreditPeriod.ToString(); txt_MaxDisc.Text = objm_Customer.MaxDisc.ToString(); txt_MinDisc.Text = objm_Customer.MinDisc.ToString(); txt_ApplyingDisc.Text = objm_Customer.ApplyingDisc.ToString(); txt_salesman.Text = objm_Customer.SalesMan; txt_AreaCode.Text = objm_Customer.Area; txt_cat.Text = objm_Customer.cat; txt_subcat.Text = objm_Customer.subcat; formMode = 0; dtx.Clear(); dataGridView2.Refresh(); M_CushasAgents req = new M_CushasAgents(); req.CustomerCode = objm_Customer.CusID.ToString(); List <M_CushasAgents> requests = new List <M_CushasAgents>(); requests = new M_CushasAgentDL().SelectM_CushasAgentMulti(req); foreach (M_CushasAgents det in requests) { commonFunctions.AddRowAgents(dtx, det.AgentCode, findExisting.FindExisitingAgent(det.AgentCode)); } } } } catch (Exception ex) { throw ex; } }
public M_CushasAgents Selectm_CushasAgent(M_CushasAgents objm_CushasAgent) { try { strquery = @"select * from m_CushasAgent where AgentCode = '" + objm_CushasAgent.AgentCode + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objm_CushasAgent.AgentCode = drType["AgentCode"].ToString(); objm_CushasAgent.CustomerCode = drType["CustomerCode"].ToString(); objm_CushasAgent.Datex = DateTime.Parse(drType["Datex"].ToString()); objm_CushasAgent.userx = drType["userx"].ToString(); return(objm_CushasAgent); } return(null); } catch (Exception ex) { throw ex; } }
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; } }