Exemplo n.º 1
0
 public M_SubCategory Selectm_SubCategory_one(M_SubCategory objm_SubCategory)
 {
     try
     {
         strquery = @"select * FROM M_subcategory WHERE codex = '" + objm_SubCategory.Codex.Trim() + "'  CategoryID = '" + objm_SubCategory.CategoryID.Trim() + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objm_SubCategory.Codex      = drType["Codex"].ToString();
             objm_SubCategory.CategoryID = drType["CategoryID"].ToString();
             objm_SubCategory.Descr      = drType["Descr"].ToString();
             objm_SubCategory.date       = DateTime.Parse(drType["date"].ToString());
             objm_SubCategory.type       = drType["type"].ToString();
             objm_SubCategory.Lockedby   = drType["Lockedby"].ToString();
             objm_SubCategory.Locked     = bool.Parse(drType["Locked"].ToString());
             objm_SubCategory.Userx      = drType["Userx"].ToString();
             return(objm_SubCategory);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Saves a record to the M_SubCategory table.
        /// </summary>
        public Boolean Savem_SubCategorySP(M_SubCategory m_SubCategory, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

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

                scom.Parameters.Add("@Codex", SqlDbType.VarChar, 20).Value      = m_SubCategory.Codex;
                scom.Parameters.Add("@CategoryID", SqlDbType.VarChar, 20).Value = m_SubCategory.CategoryID;
                scom.Parameters.Add("@Descr", SqlDbType.VarChar, 50).Value      = m_SubCategory.Descr;
                scom.Parameters.Add("@date", SqlDbType.DateTime, 8).Value       = m_SubCategory.date;
                scom.Parameters.Add("@type", SqlDbType.VarChar, 20).Value       = m_SubCategory.type;
                scom.Parameters.Add("@Lockedby", SqlDbType.VarChar, 20).Value   = m_SubCategory.Lockedby;
                scom.Parameters.Add("@Locked", SqlDbType.Bit, 1).Value          = m_SubCategory.Locked;
                scom.Parameters.Add("@Userx", SqlDbType.NChar, 10).Value        = m_SubCategory.Userx;
                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);
            }
        }
Exemplo n.º 3
0
        public List <M_SubCategory> SelectM_SubCategoryMulti(string caytegory)
        {
            List <M_SubCategory> retval = new List <M_SubCategory>();

            try
            {
                strquery = @"select * from m_SubCategory where CategoryID = '" + caytegory.Trim() + "'";
                DataTable dtm_SubCategory = u_DBConnection.ReturnDataTable(strquery, CommandType.Text);
                foreach (DataRow drType in dtm_SubCategory.Rows)
                {
                    if (drType != null)
                    {
                        M_SubCategory objm_SubCategory = new M_SubCategory();
                        objm_SubCategory.Codex      = drType["Codex"].ToString();
                        objm_SubCategory.CategoryID = drType["CategoryID"].ToString();
                        objm_SubCategory.Descr      = drType["Descr"].ToString();
                        objm_SubCategory.date       = DateTime.Parse(drType["date"].ToString());
                        objm_SubCategory.type       = drType["type"].ToString();
                        objm_SubCategory.Lockedby   = drType["Lockedby"].ToString();
                        objm_SubCategory.Locked     = bool.Parse(drType["Locked"].ToString());
                        objm_SubCategory.Userx      = drType["Userx"].ToString();
                        retval.Add(objm_SubCategory);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public static string FindExisitingsubcategory(string catecode, string subcatecode)
        {
            string str = "";

            if (M_SubCategoryDL.ExistingM_SubCategory(catecode.Trim(), subcatecode.Trim()))
            {
                M_SubCategory cat = new M_SubCategory();
                cat.Codex      = subcatecode.Trim();
                cat.CategoryID = catecode.Trim();
                str            = new M_SubCategoryDL().Selectm_SubCategory(cat).Descr;
            }
            else
            {
                str = "<Error!!!>";
            }
            return(str);
        }
Exemplo n.º 5
0
 private void SetValuesSub(String sm_Category)
 {
     try
     {
         M_SubCategory objm_Category = new M_SubCategory();
         if (sm_Category != "")
         {
             objm_Category.Codex = sm_Category;
             objm_Category       = new M_SubCategoryDL().Selectm_SubCategory(objm_Category);
             if (objm_Category != null)
             {
                 txt_subcatcode.Text = objm_Category.Codex.ToString();
                 txt_subcatname.Text = objm_Category.Descr.ToString();
                 chk_locksub.Checked = objm_Category.Locked.Value;
                 formMode            = 0;
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 6
0
        private void btn_addSub_Click(object sender, EventArgs e)
        {
            if (txt_subcatname.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_subcatname, "Please enter a subcategory name !");
                return;
            }

            lbl_newsub.Hide();
            try
            {
                if (!M_SubCategoryDL.ExistingM_SubCategory(txt_Codex.Text, txt_subcatcode.Text.Trim()))
                {
                    lbl_newsub.Show();
                    if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                    {
                        M_SubCategory objm_SubCategory = new M_SubCategory();
                        objm_SubCategory.Codex      = txt_subcatcode.Text.Trim();
                        objm_SubCategory.CategoryID = txt_Codex.Text.Trim();
                        objm_SubCategory.Descr      = txt_subcatname.Text.Trim();
                        objm_SubCategory.date       = DateTime.Now;
                        objm_SubCategory.type       = "";
                        objm_SubCategory.Lockedby   = commonFunctions.Loginuser;
                        objm_SubCategory.Locked     = chk_locksub.Checked;
                        objm_SubCategory.Userx      = commonFunctions.Loginuser;
                        new M_SubCategoryDL().Savem_SubCategorySP(objm_SubCategory, 1);

                        GetData();

                        txt_Codex.Enabled = true;
                        FunctionButtonStatus(xEnums.PerformanceType.Save);
                        UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim());
                    }
                }
                else
                {
                    lbl_newsub.Hide();
                    if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                    {
                        M_SubCategory objm_SubCategory = new M_SubCategory();
                        objm_SubCategory.Codex      = txt_subcatcode.Text.Trim();
                        objm_SubCategory.CategoryID = txt_Codex.Text.Trim();
                        objm_SubCategory.Descr      = txt_subcatname.Text.Trim();
                        objm_SubCategory.date       = DateTime.Now;
                        objm_SubCategory.type       = "";
                        objm_SubCategory.Lockedby   = commonFunctions.Loginuser;
                        objm_SubCategory.Locked     = chk_locksub.Checked;
                        objm_SubCategory.Userx      = commonFunctions.Loginuser;
                        new M_SubCategoryDL().Savem_SubCategorySP(objm_SubCategory, 3);

                        GetData();

                        txt_Codex.Enabled = true;
                        FunctionButtonStatus(xEnums.PerformanceType.Save);
                        UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_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 loading data", 1);
            }
        }