/// <summary> /// Saves a record to the M_Category table. /// </summary> public Boolean SaveM_CategorySP(M_Category m_Category, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "M_CategorySave"; scom.Parameters.Add("@Codex", SqlDbType.VarChar, 20).Value = m_Category.Codex; scom.Parameters.Add("@Descr", SqlDbType.VarChar, 50).Value = m_Category.Descr; scom.Parameters.Add("@date", SqlDbType.DateTime, 8).Value = m_Category.date; scom.Parameters.Add("@type", SqlDbType.VarChar, 20).Value = m_Category.type; scom.Parameters.Add("@Lockedby", SqlDbType.VarChar, 20).Value = m_Category.Lockedby; scom.Parameters.Add("@Locked", SqlDbType.Bit, 1).Value = m_Category.Locked; scom.Parameters.Add("@Userx", SqlDbType.NChar, 10).Value = m_Category.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); } }
public static string FindExisitingcategory(string suppcode) { string str = ""; if (M_CategoryDL.ExistingM_Category(suppcode.Trim())) { M_Category cat = new M_Category(); cat.Codex = suppcode.Trim(); str = new M_CategoryDL().Selectm_Category(cat).Descr; } else { str = "<Error!!!>"; } return(str); }
private void SetValues(String sm_Category) { try { M_Category objm_Category = new M_Category(); if (sm_Category != "") { objm_Category.Codex = sm_Category; objm_Category = new M_CategoryDL().Selectm_Category(objm_Category); if (objm_Category != null) { txt_Codex.Text = objm_Category.Codex.ToString(); txt_Descr.Text = objm_Category.Descr.ToString(); chk_catlock.Checked = objm_Category.Locked.Value; GetDataSUB(objm_Category.Codex.ToString()); formMode = 0; } } } catch (Exception ex) { } }
public M_Category Selectm_Category(M_Category objm_Category) { try { strquery = @"SELECT * FROM M_Category where Codex = '" + objm_Category.Codex.Trim() + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objm_Category.Codex = drType["Codex"].ToString(); objm_Category.Descr = drType["Descr"].ToString(); objm_Category.date = DateTime.Parse(drType["date"].ToString()); objm_Category.type = drType["type"].ToString(); objm_Category.Lockedby = drType["Lockedby"].ToString(); objm_Category.Locked = bool.Parse(drType["Locked"].ToString()); objm_Category.Userx = drType["Userx"].ToString(); return(objm_Category); } return(null); } catch (Exception ex) { throw ex; } }
private void btn_addCat_Click(object sender, EventArgs e) { if (txt_Descr.Text.Trim() == "") { errorProvider1.SetError(txt_Descr, "Please enter a category name !"); return; } if (txt_Codex.Text.Trim() == "") { errorProvider1.SetError(txt_Codex, "Please enter a category code !"); return; } lbl_new.Hide(); try { if (M_CategoryDL.ExistingM_Category(txt_Codex.Text.Trim())) { lbl_new.Hide(); if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Category objm_Category = new M_Category(); objm_Category.Codex = txt_Codex.Text.Trim(); objm_Category.Descr = txt_Descr.Text.Trim(); objm_Category.date = DateTime.Now; //txt_date.Text.Trim(); objm_Category.type = ""; //txt_type.Text.Trim(); objm_Category.Lockedby = commonFunctions.Loginuser; objm_Category.Locked = chk_catlock.Checked; //txt_Locked.Text.Trim(); objm_Category.Userx = commonFunctions.Loginuser; M_CategoryDL bal = new M_CategoryDL(); bal.SaveM_CategorySP(objm_Category, 3); GetData(); txt_Codex.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim()); } } else { lbl_new.Show(); if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Category objm_Category = new M_Category(); objm_Category.Codex = txt_Codex.Text.Trim(); objm_Category.Descr = txt_Descr.Text.Trim(); objm_Category.date = DateTime.Now; //txt_date.Text.Trim(); objm_Category.type = ""; //txt_type.Text.Trim(); objm_Category.Lockedby = commonFunctions.Loginuser; objm_Category.Locked = chk_catlock.Checked; //txt_Locked.Text.Trim(); objm_Category.Userx = commonFunctions.Loginuser; M_CategoryDL bal = new M_CategoryDL(); bal.SaveM_CategorySP(objm_Category, 1); 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); } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_Codex.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["CategoryFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["CategorySQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["CategoryField" + 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_Codex.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_Codex.Enabled = false; txt_Descr.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: try { if (formMode == 1) { if (M_CategoryDL.ExistingM_Category(txt_Codex.Text.Trim())) { errorProvider1.SetError(txt_Codex, "The category code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Category objm_Category = new M_Category(); objm_Category.Codex = txt_Codex.Text.Trim(); objm_Category.Descr = txt_Descr.Text.Trim(); objm_Category.date = DateTime.Now; //txt_date.Text.Trim(); objm_Category.type = ""; //txt_type.Text.Trim(); objm_Category.Lockedby = ""; //txt_Lockedby.Text.Trim(); objm_Category.Locked = false; //txt_Locked.Text.Trim(); objm_Category.Userx = commonFunctions.Loginuser; M_CategoryDL bal = new M_CategoryDL(); bal.SaveM_CategorySP(objm_Category, 1); GetData(); txt_Codex.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_Category objm_Category = new M_Category(); objm_Category.Codex = txt_Codex.Text.Trim(); objm_Category.Descr = txt_Descr.Text.Trim(); objm_Category.date = DateTime.Now; //txt_date.Text.Trim(); objm_Category.type = ""; //txt_type.Text.Trim(); objm_Category.Lockedby = ""; //txt_Lockedby.Text.Trim(); objm_Category.Locked = false; //txt_Locked.Text.Trim(); objm_Category.Userx = commonFunctions.Loginuser; M_CategoryDL bal = new M_CategoryDL(); bal.SaveM_CategorySP(objm_Category, 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 updating data", 1); } break; case xEnums.PerformanceType.Cancel: txt_Codex.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }