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;
            }
        }
Beispiel #2
0
        private void LoadData()
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                codex     = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                cat       = new T_OrderFormHead();
                cat.DocNo = codex.Trim();
                T_OrderFormHeadDL dl = new T_OrderFormHeadDL();
                cat = dl.Selectt_OrderFormHead(cat);

                txt_DocNo.Text           = cat.DocNo;
                txt_Locacode.Text        = cat.Locacode.Trim();
                txt_locationId_name.Text = findExisting.FindExisitingLoca(txt_Locacode.Text);
                txt_Customer.Text        = cat.Customer.Trim();
                txt_Customer_name.Text   = findExisting.FindExisitingCUstomer(txt_Customer.Text);
                txt_Remarks.Text         = cat.Remarks;
                //dte_date.Value = cat.Datex.Value;
                //dte_RecivedDate.Value = cat.RecivedDate.Value;

                txt_NetTotal.Text      = cat.NetTotal.ToString();
                txt_Subtotal.Text      = cat.Subtotal.ToString();
                txt_subtotdiscper.Text = cat.DiscountPer.ToString();
                txt_TotalDisc.Text     = cat.TotalDisc.ToString();
                txt_subtotdisc.Text    = cat.SubtotalDisc.ToString();


                M_Customers cusx = new M_Customers();
                cusx.CusID            = cat.Customer.Trim();
                cusx                  = new M_CustomerDL().Selectm_Customer(cusx);
                txt_os.Text           = cusx.customerOS.ToString();
                txt_creditlimit.Text  = cusx.CreditLimit.ToString();
                lbl_creditPeriod.Text = cusx.CreditPeriod.ToString();

                dataGridView2.DataSource       = T_OrderFormHeadDL.GetCreditNoteItems(cat.Customer.Trim());
                dataGridView2.Columns[0].Width = 120;
                dataGridView2.Columns[1].Width = 120;
                dataGridView2.Columns[2].Width = 120;
                dataGridView2.Columns[3].Width = 120;
                dataGridView2.Refresh();

                dataGridView3.DataSource       = T_OrderFormHeadDL.GetInvoiceDetails(cat.Customer.Trim());
                dataGridView3.Columns[0].Width = 120;
                dataGridView3.Columns[1].Width = 120;
                dataGridView3.Columns[2].Width = 120;
                dataGridView3.Columns[3].Width = 120;
                dataGridView3.Refresh();
            }
        }
        private void GetData()
        {
            try
            {
                M_CustomerDL bdl = new M_CustomerDL();

                DataTable dt = bdl.SelectAllm_Customer();
                dataGridView1.DataSource = dt;

                if (dataGridView1.DataSource != null)
                {
                    dataGridView1.Columns[0].HeaderText = "Customer Code";
                    dataGridView1.Columns[1].HeaderText = "Customer Name";

                    dataGridView1.Columns[0].Width = 180;
                    dataGridView1.Columns[1].Width = 540;
                }
            }
            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;
            }
        }