public M_Loca Selectm_Loca(M_Loca objm_Loca) { try { strquery = @"SELECT * FROM dbo.M_Loca WHERE Locacode = '" + objm_Loca.Locacode.Trim() + "' "; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objm_Loca.Locacode = drType["Locacode"].ToString(); objm_Loca.Companycode = drType["Companycode"].ToString(); objm_Loca.StockCode = drType["StockCode"].ToString(); objm_Loca.Locaname = drType["Locaname"].ToString(); objm_Loca.Add1 = drType["Add1"].ToString(); objm_Loca.Add2 = drType["Add2"].ToString(); objm_Loca.Add3 = drType["Add3"].ToString(); objm_Loca.Tpno = drType["Tpno"].ToString(); objm_Loca.Fax = drType["Fax"].ToString(); objm_Loca.Emailx = drType["Emailx"].ToString(); objm_Loca.Userx = drType["Userx"].ToString(); objm_Loca.Datex = DateTime.Parse(drType["Datex"].ToString()); return(objm_Loca); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// Saves a record to the M_Loca table. /// </summary> public Boolean SaveM_LocaSP(M_Loca m_Loca, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "M_LocaSave"; scom.Parameters.Add("@Locacode", SqlDbType.VarChar, 20).Value = m_Loca.Locacode; scom.Parameters.Add("@Companycode", SqlDbType.VarChar, 20).Value = m_Loca.Companycode; scom.Parameters.Add("@StockCode", SqlDbType.VarChar, 20).Value = m_Loca.StockCode; scom.Parameters.Add("@Locaname", SqlDbType.VarChar, 50).Value = m_Loca.Locaname; scom.Parameters.Add("@Add1", SqlDbType.VarChar, 50).Value = m_Loca.Add1; scom.Parameters.Add("@Add2", SqlDbType.VarChar, 50).Value = m_Loca.Add2; scom.Parameters.Add("@Add3", SqlDbType.VarChar, 50).Value = m_Loca.Add3; scom.Parameters.Add("@Tpno", SqlDbType.VarChar, 20).Value = m_Loca.Tpno; scom.Parameters.Add("@Fax", SqlDbType.VarChar, 20).Value = m_Loca.Fax; scom.Parameters.Add("@Emailx", SqlDbType.VarChar, 50).Value = m_Loca.Emailx; scom.Parameters.Add("@Userx", SqlDbType.VarChar, 20).Value = m_Loca.Userx; scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value = m_Loca.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); } }
private void SetValues(String sm_Loca) { try { M_LocaDL objm_LocaDL = new M_LocaDL(); M_Loca objm_Loca = new M_Loca(); if (sm_Loca != "") { objm_Loca.Locacode = sm_Loca; objm_Loca = objm_LocaDL.Selectm_Loca(objm_Loca); if (objm_Loca != null) { txt_Locacode.Text = objm_Loca.Locacode.ToString(); txt_Locaname.Text = objm_Loca.Companycode.ToString(); //txt_StockCode.Text = objm_Loca.StockCode.ToString(); txt_Locaname.Text = objm_Loca.Locaname.ToString(); txt_Add1.Text = objm_Loca.Add1.ToString(); txt_Add2.Text = objm_Loca.Add2.ToString(); txt_Add3.Text = objm_Loca.Add3.ToString(); txt_Tpno.Text = objm_Loca.Tpno.ToString(); txt_Fax.Text = objm_Loca.Fax.ToString(); txt_Emailx.Text = objm_Loca.Emailx.ToString(); //txt_Userx.Text = objm_Loca.Userx.ToString(); //txt_Datex.Text = objm_Loca.Datex.ToString(); formMode = 3; } } } catch (Exception ex) { throw ex; } }
public static string FindExisitingLoca(string locacode) { string str = ""; if (M_LocaDL.ExistingM_Loca(locacode.Trim())) { M_Loca cat = new M_Loca(); cat.Locacode = locacode.Trim(); M_LocaDL dl = new M_LocaDL(); cat = dl.Selectm_Loca(cat); str = cat.Locaname; } else { str = "<Error!!!>"; } return(str); }
private void FindExisitingLoca(string locacode) { try{ if (M_LocaDL.ExistingM_Loca(locacode.Trim())) { M_Loca cat = new M_Loca(); cat.Locacode = locacode.Trim(); M_LocaDL dl = new M_LocaDL(); cat = dl.Selectm_Loca(cat); txt_location.Text = cat.Locacode.Trim(); txt_locaname.Text = cat.Locaname; } else { txt_locaname.Text = "<Location Not Exists.>"; } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error", 1); } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_Locacode.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["BankFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["BankSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["BankField" + 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_Locacode.Focus(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_Locacode.Enabled = false; txt_Locaname.Focus(); break; case xEnums.PerformanceType.Save: if (formMode == 1) { if (M_LocaDL.ExistingM_Loca(txt_Locacode.Text.Trim())) { UserDefineMessages.ShowMsg("The location code you have entered already exists!", UserDefineMessages.Msg_Warning); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Loca objm_Loca = new M_Loca(); objm_Loca.Locacode = txt_Locacode.Text.Trim(); objm_Loca.Companycode = commonFunctions.GlobalCompany.Trim(); objm_Loca.StockCode = txt_Locacode.Text.Trim(); objm_Loca.Locaname = txt_Locaname.Text.Trim(); objm_Loca.Add1 = txt_Add1.Text.Trim(); objm_Loca.Add2 = txt_Add2.Text.Trim(); objm_Loca.Add3 = txt_Add3.Text.Trim(); objm_Loca.Tpno = txt_Tpno.Text.Trim(); objm_Loca.Fax = txt_Fax.Text.Trim(); objm_Loca.Emailx = txt_Emailx.Text.Trim(); objm_Loca.Userx = commonFunctions.Loginuser; objm_Loca.Datex = DateTime.Now; M_LocaDL bal = new M_LocaDL(); bal.SaveM_LocaSP(objm_Loca, 1); GetData(); txt_Locacode.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_Loca objm_Loca = new M_Loca(); objm_Loca.Locacode = txt_Locacode.Text.Trim(); objm_Loca.Companycode = commonFunctions.GlobalCompany.Trim(); objm_Loca.StockCode = txt_Locacode.Text.Trim(); objm_Loca.Locaname = txt_Locaname.Text.Trim(); objm_Loca.Add1 = txt_Add1.Text.Trim(); objm_Loca.Add2 = txt_Add2.Text.Trim(); objm_Loca.Add3 = txt_Add3.Text.Trim(); objm_Loca.Tpno = txt_Tpno.Text.Trim(); objm_Loca.Fax = txt_Fax.Text.Trim(); objm_Loca.Emailx = txt_Emailx.Text.Trim(); objm_Loca.Userx = commonFunctions.Loginuser; objm_Loca.Datex = DateTime.Now; M_LocaDL bal = new M_LocaDL(); bal.SaveM_LocaSP(objm_Loca, 3); GetData(); txt_Locacode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_Locacode.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }