private void SetValues(String sm_Vehicle) { try { M_VehicleDL objm_VehicleDL = new M_VehicleDL(); M_Vehicles objm_Vehicle = new M_Vehicles(); if (sm_Vehicle != "") { objm_Vehicle.VehicleID = sm_Vehicle; objm_Vehicle = objm_VehicleDL.Selectm_Vehicle(objm_Vehicle); if (objm_Vehicle != null) { incomingvehicle = objm_Vehicle.VehicleNo.ToString(); txt_VehicleID.Text = objm_Vehicle.VehicleID.ToString(); txt_VehicleNo.Text = objm_Vehicle.VehicleNo.ToString(); //txt_CompCode.Text = objm_Vehicle.CompCode.ToString(); //txt_Locacode.Text = objm_Vehicle.Locacode.ToString(); txt_Make.Text = objm_Vehicle.Make.ToString(); txt_Model.Text = objm_Vehicle.Model.ToString(); txt_Driver.Text = objm_Vehicle.Driver.ToString(); txt_Milage.Text = objm_Vehicle.Milage.ToString(); txt_FuelEfficiency.Text = objm_Vehicle.FuelEfficiency.ToString(); txt_Status.Text = objm_Vehicle.Status.ToString(); txt_Route.Text = objm_Vehicle.Route.ToString(); //txt_Userx.Text = objm_Vehicle.Userx.ToString(); //txt_Datex.Text = objm_Vehicle.Datex.ToString(); formMode = 3; } } } catch (Exception ex) { throw ex; } }
public M_Vehicles Selectm_Vehicle(M_Vehicles objm_Vehicle) { try { strquery = @"select * from M_Vehicles where VehicleID = '" + objm_Vehicle.VehicleID.Trim() + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objm_Vehicle.VehicleID = drType["VehicleID"].ToString(); objm_Vehicle.VehicleNo = drType["VehicleNo"].ToString(); objm_Vehicle.CompCode = drType["CompCode"].ToString(); objm_Vehicle.Locacode = drType["Locacode"].ToString(); objm_Vehicle.Make = drType["Make"].ToString(); objm_Vehicle.Model = drType["Model"].ToString(); objm_Vehicle.Driver = drType["Driver"].ToString(); objm_Vehicle.Milage = drType["Milage"].ToString(); objm_Vehicle.FuelEfficiency = decimal.Parse(drType["FuelEfficiency"].ToString()); objm_Vehicle.Status = drType["Status"].ToString(); objm_Vehicle.Route = drType["Route"].ToString(); objm_Vehicle.Userx = drType["Userx"].ToString(); objm_Vehicle.Datex = DateTime.Parse(drType["Datex"].ToString()); return(objm_Vehicle); } return(null); } catch (Exception ex) { throw ex; } }
public static string FindExisitingVehicle(string suppcode) { string str = ""; if (M_VehicleDL.ExistingM_Vehicle(suppcode.Trim())) { M_Vehicles cat = new M_Vehicles(); cat.VehicleID = suppcode.Trim(); M_VehicleDL dl = new M_VehicleDL(); cat = dl.Selectm_Vehicle(cat); str = cat.VehicleNo; } else { str = "<Error!!!>"; } return(str); }
/// <summary> /// Saves a record to the M_Vehicles table. /// </summary> public Boolean SaveM_VehicleSP(M_Vehicles m_Vehicle, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "M_VehiclesSave"; scom.Parameters.Add("@VehicleID", SqlDbType.VarChar, 20).Value = m_Vehicle.VehicleID; scom.Parameters.Add("@VehicleNo", SqlDbType.VarChar, 20).Value = m_Vehicle.VehicleNo; scom.Parameters.Add("@CompCode", SqlDbType.VarChar, 20).Value = m_Vehicle.CompCode; scom.Parameters.Add("@Locacode", SqlDbType.VarChar, 20).Value = m_Vehicle.Locacode; scom.Parameters.Add("@Make", SqlDbType.VarChar, 30).Value = m_Vehicle.Make; scom.Parameters.Add("@Model", SqlDbType.VarChar, 30).Value = m_Vehicle.Model; scom.Parameters.Add("@Driver", SqlDbType.VarChar, 50).Value = m_Vehicle.Driver; scom.Parameters.Add("@Milage", SqlDbType.VarChar, 50).Value = m_Vehicle.Milage; scom.Parameters.Add("@FuelEfficiency", SqlDbType.Decimal, 9).Value = m_Vehicle.FuelEfficiency; scom.Parameters.Add("@Status", SqlDbType.VarChar, 20).Value = m_Vehicle.Status; scom.Parameters.Add("@Route", SqlDbType.VarChar, 20).Value = m_Vehicle.Route; scom.Parameters.Add("@Userx", SqlDbType.VarChar, 20).Value = m_Vehicle.Userx; scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value = m_Vehicle.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 performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_VehicleID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["VehicleFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["VehicleSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["VehicleField" + 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_VehicleID.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_VehicleID.Enabled = false; txt_VehicleNo.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: errorProvider1.Clear(); if (txt_VehicleNo.Text.Trim() == "") { errorProvider1.SetError(txt_VehicleNo, "Please enter a vehicle number !"); return; } if (txt_VehicleID.Text.Trim() == "") { errorProvider1.SetError(txt_VehicleID, "Please enter a vehicle ID !"); return; } if (incomingvehicle.Trim().ToUpper() != txt_VehicleNo.Text.Trim()) { if (M_VehicleDL.ExistingM_VehicleNo(txt_VehicleNo.Text.Trim())) { errorProvider1.SetError(txt_VehicleNo, "The vehicle number you have entered already exists!"); return; } } if (formMode == 1) { if (M_VehicleDL.ExistingM_Vehicle(txt_VehicleID.Text.Trim())) { errorProvider1.SetError(txt_VehicleID, "The vehicle code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Vehicles objm_Vehicle = new M_Vehicles(); objm_Vehicle.VehicleID = txt_VehicleID.Text.Trim(); objm_Vehicle.VehicleNo = txt_VehicleNo.Text.Trim(); objm_Vehicle.CompCode = commonFunctions.GlobalCompany; //txt_CompCode.Text.Trim(); objm_Vehicle.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Vehicle.Make = txt_Make.Text.Trim(); objm_Vehicle.Model = txt_Model.Text.Trim(); objm_Vehicle.Driver = txt_Driver.Text.Trim(); objm_Vehicle.Milage = txt_Milage.Text.Trim(); objm_Vehicle.FuelEfficiency = commonFunctions.ToDecimal(txt_FuelEfficiency.Text.Trim()); objm_Vehicle.Status = txt_Status.Text.Trim(); objm_Vehicle.Route = txt_Route.Text.Trim(); objm_Vehicle.Userx = commonFunctions.Loginuser; //txt_Userx.Text.Trim(); objm_Vehicle.Datex = DateTime.Now; //txt_Datex.Text.Trim(); M_VehicleDL bal = new M_VehicleDL(); bal.SaveM_VehicleSP(objm_Vehicle, 1); GetData(); txt_VehicleID.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_Vehicles objm_Vehicle = new M_Vehicles(); objm_Vehicle.VehicleID = txt_VehicleID.Text.Trim(); objm_Vehicle.VehicleNo = txt_VehicleNo.Text.Trim(); objm_Vehicle.CompCode = commonFunctions.GlobalCompany; //txt_CompCode.Text.Trim(); objm_Vehicle.Locacode = commonFunctions.GlobalLocation; //txt_Locacode.Text.Trim(); objm_Vehicle.Make = txt_Make.Text.Trim(); objm_Vehicle.Model = txt_Model.Text.Trim(); objm_Vehicle.Driver = txt_Driver.Text.Trim(); objm_Vehicle.Milage = txt_Milage.Text.Trim(); objm_Vehicle.FuelEfficiency = commonFunctions.ToDecimal(txt_FuelEfficiency.Text.Trim()); objm_Vehicle.Status = txt_Status.Text.Trim(); objm_Vehicle.Route = txt_Route.Text.Trim(); objm_Vehicle.Userx = commonFunctions.Loginuser; //txt_Userx.Text.Trim(); objm_Vehicle.Datex = DateTime.Now; //txt_Datex.Text.Trim(); M_VehicleDL bal = new M_VehicleDL(); bal.SaveM_VehicleSP(objm_Vehicle, 3); GetData(); txt_VehicleID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_VehicleID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }