Exemple #1
0
 private void SetValues(String sm_Route)
 {
     try
     {
         M_RouteDL objm_RouteDL = new M_RouteDL();
         M_Route   objm_Route   = new M_Route();
         if (sm_Route != "")
         {
             objm_Route.Routecode = sm_Route;
             objm_Route           = objm_RouteDL.Selectm_Route(objm_Route);
             if (objm_Route != null)
             {
                 txt_Routecode.Text     = objm_Route.Routecode.ToString();
                 txt_TerritoryCode.Text = objm_Route.TerritoryCode.ToString();
                 txt_AreaCode.Text      = objm_Route.AreaCode.ToString();
                 txt_Descr.Text         = objm_Route.Descr.ToString();
                 formMode = 0;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        private void GetData()
        {
            try
            {
                M_RouteDL bdl = new M_RouteDL();
                dataGridView1.DataSource = bdl.SelectAllm_Route();

                if (dataGridView1.DataSource != null)
                {
                    dataGridView1.Columns[0].Width = 120;
                    dataGridView1.Columns[1].Width = 585;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
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;
            }
        }