示例#1
0
        /// <summary>
        /// Saves a record to the M_CustomerSub table.
        /// </summary>
        public Boolean Savem_CustomerSubSP(M_CustomerSub m_CustomerSub, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

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

                scom.Parameters.Add("@CussubID", SqlDbType.VarChar, 20).Value     = m_CustomerSub.CussubID;
                scom.Parameters.Add("@CatID", SqlDbType.VarChar, 20).Value        = m_CustomerSub.CatID;
                scom.Parameters.Add("@Description", SqlDbType.VarChar, 120).Value = m_CustomerSub.Description;
                scom.Parameters.Add("@Userx", SqlDbType.VarChar, 20).Value        = m_CustomerSub.Userx;
                scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value        = m_CustomerSub.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);
            }
        }
示例#2
0
        public List <M_CustomerSub> SelectM_CustomerSubMulti(M_CustomerSub objm_CustomerSub2)
        {
            List <M_CustomerSub> retval = new List <M_CustomerSub>();

            try
            {
                strquery = @"select * from m_CustomerSub where CussubID = '" + objm_CustomerSub2.CussubID + "'";
                DataTable dtm_CustomerSub = u_DBConnection.ReturnDataTable(strquery, CommandType.Text);
                foreach (DataRow drType in dtm_CustomerSub.Rows)
                {
                    if (drType != null)
                    {
                        M_CustomerSub objm_CustomerSub = new M_CustomerSub();
                        objm_CustomerSub.CussubID    = drType["CussubID"].ToString();
                        objm_CustomerSub.CatID       = drType["CatID"].ToString();
                        objm_CustomerSub.Description = drType["Description"].ToString();
                        objm_CustomerSub.Userx       = drType["Userx"].ToString();
                        objm_CustomerSub.Datex       = DateTime.Parse(drType["Datex"].ToString());
                        retval.Add(objm_CustomerSub);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public static string FindExisitingCustomerSub(string catid, string subcatid)
        {
            string str = "";

            if (M_CustomerSubDL.ExistingM_CustomerSub(subcatid, catid.Trim()))
            {
                M_CustomerSub cat = new M_CustomerSub();
                cat.CatID    = catid.Trim();
                cat.CussubID = subcatid.Trim();
                str          = new M_CustomerSubDL().Selectm_CustomerSub(cat).Description;
            }
            else
            {
                str = "<Error!!!>";
            }
            return(str);
        }
示例#4
0
 public M_CustomerSub Selectm_CustomerSub(M_CustomerSub objm_CustomerSub)
 {
     try
     {
         strquery = @"select * from m_CustomerSub where CussubID = '" + objm_CustomerSub.CussubID + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objm_CustomerSub.CussubID    = drType["CussubID"].ToString();
             objm_CustomerSub.CatID       = drType["CatID"].ToString();
             objm_CustomerSub.Description = drType["Description"].ToString();
             objm_CustomerSub.Userx       = drType["Userx"].ToString();
             objm_CustomerSub.Datex       = DateTime.Parse(drType["Datex"].ToString());
             return(objm_CustomerSub);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
 private void SetValuesSub(String sm_Category)
 {
     try
     {
         M_CustomerSub objm_Category = new M_CustomerSub();
         if (sm_Category != "")
         {
             objm_Category.CussubID = sm_Category;
             objm_Category          = new M_CustomerSubDL().Selectm_CustomerSub(objm_Category);
             if (objm_Category != null)
             {
                 txt_subcatcode.Text = objm_Category.CussubID.ToString();
                 txt_subcatname.Text = objm_Category.Description.ToString();
                 chk_locksub.Checked = false;
                 formMode            = 0;
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
示例#6
0
        private void btn_addSub_Click(object sender, EventArgs e)
        {
            if (txt_subcatcode.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_subcatcode, "Please enter a customer subcategory code !");
                return;
            }

            if (txt_subcatname.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_subcatname, "Please enter a customer subcategory !");
                return;
            }

            lbl_newsub.Hide();
            try
            {
                if (!M_CustomerSubDL.ExistingM_CustomerSub(txt_subcatcode.Text.Trim(), txt_Codex.Text))
                {
                    lbl_newsub.Show();
                    if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                    {
                        M_CustomerSub objm_SubCategory = new M_CustomerSub();
                        objm_SubCategory.CussubID    = txt_subcatcode.Text.Trim();
                        objm_SubCategory.CatID       = txt_Codex.Text.Trim();
                        objm_SubCategory.Description = txt_subcatname.Text.Trim();
                        objm_SubCategory.Userx       = commonFunctions.Loginuser;
                        objm_SubCategory.Datex       = DateTime.Now;
                        new M_CustomerSubDL().Savem_CustomerSubSP(objm_SubCategory, 1);

                        GetData();

                        txt_Codex.Enabled = true;
                        FunctionButtonStatus(xEnums.PerformanceType.Save);
                        commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2);
                    }
                }
                else
                {
                    lbl_newsub.Hide();
                    if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                    {
                        M_CustomerSub objm_SubCategory = new M_CustomerSub();
                        objm_SubCategory.CussubID    = txt_subcatcode.Text.Trim();
                        objm_SubCategory.CatID       = txt_Codex.Text.Trim();
                        objm_SubCategory.Description = txt_subcatname.Text.Trim();
                        objm_SubCategory.Userx       = commonFunctions.Loginuser;
                        objm_SubCategory.Datex       = DateTime.Now;
                        new M_CustomerSubDL().Savem_CustomerSubSP(objm_SubCategory, 3);

                        GetData();

                        txt_Codex.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);
            }
        }