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) { } }
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); } }