Beispiel #1
0
        /// <summary>
        /// Saves a record to the M_Territory table.
        /// </summary>
        public Boolean SaveM_TerritorySP(M_Territory m_Territory, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

            try
            {
                scom             = new SqlCommand();
                scom.CommandType = CommandType.StoredProcedure;
                scom.CommandText = "M_TerritorySave";

                scom.Parameters.Add("@TerritoryCode", SqlDbType.VarChar, 20).Value = m_Territory.TerritoryCode;
                scom.Parameters.Add("@Compcode", SqlDbType.VarChar, 20).Value      = m_Territory.Compcode;
                scom.Parameters.Add("@Locacode", SqlDbType.VarChar, 20).Value      = m_Territory.Locacode;
                scom.Parameters.Add("@AreaCode", SqlDbType.VarChar, 20).Value      = m_Territory.AreaCode;
                scom.Parameters.Add("@Descr", SqlDbType.VarChar, 50).Value         = m_Territory.Descr;
                scom.Parameters.Add("@UserNamex", SqlDbType.VarChar, 20).Value     = m_Territory.UserNamex;
                scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value         = m_Territory.Datex;
                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);
            }
        }
Beispiel #2
0
        private void txt_TerritoryCode_TextChanged(object sender, EventArgs e)
        {
            string tericode = txt_TerritoryCode.Text;

            txt_Areaname.Text = findExisting.FindExisitingTerri(tericode);
            if (txt_Areaname.Text.Trim().ToUpper() == "<Error!!!>".Trim().ToUpper())
            {
                return;
            }
            else
            {
                M_Territory te = new M_Territory();
                te.TerritoryCode  = txt_TerritoryCode.Text;
                txt_AreaCode.Text = new M_TerritoryDL().Selectm_Territory(te).AreaCode.Trim();
            }
        }
Beispiel #3
0
        public static string FindExisitingTerri(string suppcode)
        {
            string str = "";

            if (M_TerritoryDL.ExistingM_Territory(suppcode.Trim()))
            {
                M_Territory cat = new M_Territory();
                cat.TerritoryCode = suppcode.Trim();
                str = new M_TerritoryDL().Selectm_Territory(cat).Descr;
            }
            else
            {
                str = "<Error!!!>";
            }
            return(str);
        }
Beispiel #4
0
 public M_Territory Selectm_Territory(M_Territory objm_Territory)
 {
     try
     {
         strquery = @"select * from M_Territory where TerritoryCode = '" + objm_Territory.TerritoryCode + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objm_Territory.TerritoryCode = drType["TerritoryCode"].ToString();
             objm_Territory.Compcode      = drType["Compcode"].ToString();
             objm_Territory.Locacode      = drType["Locacode"].ToString();
             objm_Territory.AreaCode      = drType["AreaCode"].ToString();
             objm_Territory.Descr         = drType["Descr"].ToString();
             objm_Territory.UserNamex     = drType["UserNamex"].ToString();
             objm_Territory.Datex         = DateTime.Parse(drType["Datex"].ToString());
             return(objm_Territory);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #5
0
 private void SetValues(String sm_Territory)
 {
     try
     {
         M_TerritoryDL objm_TerritoryDL = new M_TerritoryDL();
         M_Territory   objm_Territory   = new M_Territory();
         if (sm_Territory != "")
         {
             objm_Territory.TerritoryCode = sm_Territory;
             objm_Territory = objm_TerritoryDL.Selectm_Territory(objm_Territory);
             if (objm_Territory != null)
             {
                 txt_TerritoryCode.Text = objm_Territory.TerritoryCode.ToString();
                 txt_AreaCode.Text      = objm_Territory.AreaCode.ToString();
                 txt_Descr.Text         = objm_Territory.Descr.ToString();
                 formMode = 3;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #6
0
        private void performButtons(xEnums.PerformanceType xenum)
        {
            switch (xenum)
            {
            case xEnums.PerformanceType.View:

                if (ActiveControl.Name.Trim() == txt_TerritoryCode.Name.Trim())
                {
                    int      length         = Convert.ToInt32(ConfigurationManager.AppSettings["TerritoryFieldLength"]);
                    string[] strSearchField = new string[length];

                    string strSQL = ConfigurationManager.AppSettings["TerritorySQL"].ToString();

                    for (int i = 0; i < length; i++)
                    {
                        string m;
                        m = i.ToString();
                        strSearchField[i] = ConfigurationManager.AppSettings["TerritoryField" + 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_TerritoryCode.Focus();
                errorProvider1.Clear();
                break;

            case xEnums.PerformanceType.Edit:
                FunctionButtonStatus(xEnums.PerformanceType.Edit);
                formMode = 3;
                txt_TerritoryCode.Enabled = false;
                txt_Descr.Focus();
                errorProvider1.Clear();
                break;

            case xEnums.PerformanceType.Save:
                try
                {
                    if (txt_Descr.Text.Trim() == "")
                    {
                        errorProvider1.SetError(txt_Descr, "Please enter a terratory name !");
                        return;
                    }

                    if (txt_TerritoryCode.Text.Trim() == "")
                    {
                        errorProvider1.SetError(txt_TerritoryCode, "Please enter a terratory code !");
                        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 (M_TerritoryDL.ExistingM_Territory(txt_TerritoryCode.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_TerritoryCode, "The territory code you have entered already exists!");
                            return;
                        }

                        if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                        {
                            M_Territory objm_Territory = new M_Territory();
                            objm_Territory.TerritoryCode = txt_TerritoryCode.Text.Trim();
                            objm_Territory.Compcode      = commonFunctions.GlobalCompany;  // txt_Compcode.Text.Trim();
                            objm_Territory.Locacode      = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim();
                            objm_Territory.AreaCode      = txt_AreaCode.Text.Trim();
                            objm_Territory.Descr         = txt_Descr.Text.Trim();
                            objm_Territory.UserNamex     = commonFunctions.Loginuser; //txt_UserNamex.Text.Trim();
                            objm_Territory.Datex         = DateTime.Now;
                            M_TerritoryDL bal = new M_TerritoryDL();
                            bal.SaveM_TerritorySP(objm_Territory, 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_Territory objm_Territory = new M_Territory();
                            objm_Territory.TerritoryCode = txt_TerritoryCode.Text.Trim();
                            objm_Territory.Compcode      = commonFunctions.GlobalCompany;  // txt_Compcode.Text.Trim();
                            objm_Territory.Locacode      = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim();
                            objm_Territory.AreaCode      = txt_AreaCode.Text.Trim();
                            objm_Territory.Descr         = txt_Descr.Text.Trim();
                            objm_Territory.UserNamex     = commonFunctions.Loginuser; //txt_UserNamex.Text.Trim();
                            objm_Territory.Datex         = DateTime.Now;
                            M_TerritoryDL bal = new M_TerritoryDL();
                            bal.SaveM_TerritorySP(objm_Territory, 3);


                            GetData();
                            txt_TerritoryCode.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_TerritoryCode.Enabled = true;
                FunctionButtonStatus(xEnums.PerformanceType.Default);
                errorProvider1.Clear();
                break;

            case xEnums.PerformanceType.Print:
                UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information);
                break;
            }
        }