Exemplo n.º 1
0
 private void SetValues(String sm_Area)
 {
     try
     {
         M_AreaDL objm_AreaDL = new M_AreaDL();
         M_Area   objm_Area   = new M_Area();
         if (sm_Area != "")
         {
             objm_Area.AreaCode = sm_Area;
             objm_Area          = objm_AreaDL.Selectm_Area(objm_Area);
             if (objm_Area != null)
             {
                 txt_AreaCode.Text = objm_Area.AreaCode.ToString();
                 //txt_Compcode.Text = "";// objm_Area.Compcode.ToString();
                 //txt_Locacode.Text = objm_Area.Locacode.ToString();
                 txt_Descri.Text = objm_Area.Descri.ToString();
                 //txt_Datex.Text = objm_Area.Datex.ToString();
                 //txt_Userx.Text = objm_Area.Userx.ToString();
                 formMode = 3;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txt_AreaCode.Text.Trim() != "" && txt_Areaname.Text.Trim() != "")
     {
         if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
         {
             if (M_AreaDL.ExistingM_Area(txt_AreaCode.Text.Trim()))
             {
                 M_Area cat = new M_Area();
                 cat.AreaCode = txt_AreaCode.Text.Trim();
                 M_AreaDL dl = new M_AreaDL();
                 cat = dl.Selectm_Area(cat);
                 txt_AreaCode.Text = cat.AreaCode.Trim();
                 txt_Areaname.Text = cat.Descri;
             }
             else
             {
                 M_Area objm_Category = new M_Area();
                 objm_Category.AreaCode = txt_AreaCode.Text.Trim();
                 objm_Category.Descri   = txt_Areaname.Text.Trim();
                 objm_Category.Datex    = DateTime.Now;
                 objm_Category.Locacode = "";
                 objm_Category.Userx    = commonFunctions.Loginuser;
                 objm_Category.Compcode = commonFunctions.GlobalCompany;
                 objm_Category.Userx    = commonFunctions.Loginuser;
                 M_AreaDL bal = new M_AreaDL();
                 bal.SaveM_AreaSP(objm_Category, 1);
             }
         }
     }
 }
Exemplo n.º 3
0
 private void FindExisitingCategory()
 {
     if (M_AreaDL.ExistingM_Area(txt_AreaCode.Text.Trim()))
     {
         M_Area cat = new M_Area();
         cat.AreaCode = txt_AreaCode.Text.Trim();
         M_AreaDL dl = new M_AreaDL();
         cat = dl.Selectm_Area(cat);
         txt_AreaCode.Text = cat.AreaCode.Trim();
         txt_Areaname.Text = cat.Descri;
     }
     else
     {
         txt_Areaname.Text = "<Area Not Exists.>";
     }
 }
Exemplo n.º 4
0
        private void GetData()
        {
            try
            {
                M_AreaDL bdl = new M_AreaDL();
                dataGridView1.DataSource = bdl.SelectAllm_Area();

                if (dataGridView1.DataSource != null)
                {
                    dataGridView1.Columns[0].Width = 120;
                    dataGridView1.Columns[1].Width = 585;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        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;
            }
        }
Exemplo n.º 8
0
        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;
            }
        }