public clsUserCar GetData(string uccode) { clsUserCar objusercar; myDB = new DBHelper(); objusercar = new clsUserCar(); sSQL = objusercar.DispDataCode(uccode); SqlDataReader sDr = myDB.GetFromReader(sSQL); sDr.Read(); if (sDr.HasRows) { objusercar.UCcode = Convert.ToInt32(sDr["UCcode"].ToString()); objusercar.CarCode = Convert.ToInt32(sDr["CarCode"].ToString()); objusercar.BrandCode = Convert.ToInt32(sDr["BrandCode"].ToString()); objusercar.RegNo = sDr["RegNo"].ToString(); objusercar.EngineNo = sDr["EngineNo"].ToString(); objusercar.ChasisNo = sDr["ChasisNo"].ToString(); objusercar.BuyDate = Convert.ToDateTime(sDr["BuyDate"].ToString()); objusercar.UserName = sDr["UserName"].ToString(); objusercar.Status = sDr["Status"].ToString(); objusercar.TransmissionMode = sDr["TransmissionMode"].ToString(); objusercar.FuelType = sDr["FuelType"].ToString(); objusercar.ModelYear = sDr["ModelYear"].ToString(); } return(objusercar); }
protected void Page_Load(object sender, EventArgs e) { objtcchange = new clsUserCar(); sCOM = new Common(); if (!Page.IsPostBack) { sSQL = objtcchange.DispDataAll(); //To Fill Gridview sCOM.setGridView(GridView1, sSQL); } }
protected void Page_Load(object sender, EventArgs e) { objbrandmaster = new clsBrandMaster(); objusercar = new clsUserCar(); sCOM = new Common(); uname = (String)Session["uname"]; if (uname != null) { txtuname.Text = uname; } else { txtuname.Text = "travelagent"; } if (!Page.IsPostBack) { sSQL = objbrandmaster.DispDataAll(); //To fill Dropdownlist sCOM.setDropDownList(DropDownList1, sSQL, "BrandName", "BrandCode"); /* if (Request.QueryString["action"] == "add") * { * txtuccode.Text = sCOM.setAutoID("UserCar", "UCcode").ToString(); * } * else if (Request.QueryString["action"] == "edit") * { * * if (Request.QueryString["ec"] != null) * { * string ec = (Request.QueryString["ec"].ToString()); * objusercar = objusercar.GetData(ec); * txtuccode.Text = objusercar.UCcode; * txtcarcode.Text = objusercar.CarCode; * txtregno.Text = objusercar.RegNo; * txtengno.Text = objusercar.EngineNo; * txtchasisno.Text = objusercar.ChasisNo; * txtbuydte.Text = objusercar.BuyDate; * txtuname.Text = objusercar.UserName; * * * } * }*/ } else { //Error Page } }
protected void Page_Load(object sender, EventArgs e) { objusercar = new clsUserCar(); objcarpuc = new clsCarPUC(); sCOM = new Common(); uname = (String)Session["uname"]; if (uname != null) { txtuname.Text = uname; } else { txtuname.Text = "travelagent"; } if (!Page.IsPostBack) { sSQL = objusercar.DispDataUsername("Apeksha"); //To fill Dropdownlist sCOM.setDropDownList(DropDownList1, sSQL, "RegNo", "UCcode"); if (Request.QueryString["action"] == "add") { txtpuccode.Text = sCOM.setAutoID("CarPUC", "PUCCode").ToString(); } else if (Request.QueryString["action"] == "edit") { if (Request.QueryString["ec"] != null) { string ec = (Request.QueryString["ec"].ToString()); objcarpuc = objcarpuc.GetData(ec); txtpuccode.Text = ec;// objcarpuc.PUCCode.ToString(); // txtcarcode.Text = objcarpuc.CarCode.ToString(); txtuname.Text = objcarpuc.UserName; txtpucdate.Text = objcarpuc.PUCDate.ToString(); txtpucno.Text = objcarpuc.PUCNo; txtvalidity.Text = objcarpuc.Validity.ToString(); txtexpdate.Text = objcarpuc.ExpDate.ToString(); txtagencyname.Text = objcarpuc.AgencyName; } } else { //Error Page } } }
public void InsertData(clsUserCar objusercar) { cmd = new SqlCommand(); myDB = new DBHelper(); sSQL = "INSERT into UserCar(CarCode,BrandCode,RegNo,EngineNo,ChasisNo,BuyDate,UserName,Status,TransmissionMode,FuelType,ModelYear)values (@CarCode,@BrandCode,@RegNo,@EngineNo,@ChasisNo,@BuyDate,@UserName,@Status,@TransmissionMode,@FuelType,@ModelYear)"; cmd.Parameters.AddWithValue("@CarCode", objusercar.CarCode); cmd.Parameters.AddWithValue("@BrandCode", objusercar.BrandCode); cmd.Parameters.AddWithValue("@RegNo", objusercar.RegNo); cmd.Parameters.AddWithValue("@EngineNo", objusercar.EngineNo); cmd.Parameters.AddWithValue("@ChasisNo", objusercar.ChasisNo); cmd.Parameters.AddWithValue("@BuyDate", objusercar.BuyDate); cmd.Parameters.AddWithValue("@UserName", objusercar.UserName); cmd.Parameters.AddWithValue("@Status", objusercar.Status); cmd.Parameters.AddWithValue("@TransmissionMode", objusercar.TransmissionMode); cmd.Parameters.AddWithValue("@FuelType", objusercar.FuelType); cmd.Parameters.AddWithValue("@ModelYear", objusercar.ModelYear); myDB.Execute(sSQL, cmd); }
public void UpdateData(clsUserCar objusercar, string uccode) { cmd = new SqlCommand(); myDB = new DBHelper(); sSQL = "UPDATE UserCar set UCcode=@UCcode,CarCode=@CarCode,BrandCode=@BrandCode,RegNo=@RegNo,EngineNo=@EngineNo,ChasisNo=@ChasisNo,BuyDate=@BuyDate,UserName=@UserName,Status=@Status,TransmissionMode=@TransmissionMode,FuelType=@FuelType,ModelYear=@ModelYear where UCcode=" + uccode; cmd.Parameters.AddWithValue("@UCcode", objusercar.UCcode); cmd.Parameters.AddWithValue("@CarCode", objusercar.CarCode); cmd.Parameters.AddWithValue("@BrandCode", objusercar.BrandCode); cmd.Parameters.AddWithValue("@RegNo", objusercar.RegNo); cmd.Parameters.AddWithValue("@EngineNo", objusercar.EngineNo); cmd.Parameters.AddWithValue("@ChasisNo", objusercar.ChasisNo); cmd.Parameters.AddWithValue("@BuyDate", objusercar.BuyDate); cmd.Parameters.AddWithValue("@UserName", objusercar.UserName); cmd.Parameters.AddWithValue("@Status", objusercar.Status); cmd.Parameters.AddWithValue("@TransmissionMode", objusercar.TransmissionMode); cmd.Parameters.AddWithValue("@FuelType", objusercar.FuelType); cmd.Parameters.AddWithValue("@ModelYear", objusercar.ModelYear); myDB.Execute(sSQL, cmd); }
protected void btnsave_Click(object sender, EventArgs e) { objusercar = new clsUserCar(); try { // objusercar.UCcode = Convert.ToInt32(txtuccode.Text); objusercar.UserName = txtuname.Text; objusercar.CarCode = Convert.ToInt32(txtcarcode.Text); objusercar.BrandCode = Convert.ToInt32(DropDownList1.SelectedValue); objusercar.RegNo = txtregno.Text; objusercar.EngineNo = txtengno.Text; objusercar.ChasisNo = txtchasisno.Text; objusercar.BuyDate = Convert.ToDateTime(txtbuydte.Text); objusercar.UserName = txtuname.Text; objusercar.ModelYear = txtmodelyr.Text; objusercar.TransmissionMode = DropDownList3.SelectedValue; objusercar.FuelType = DropDownList2.SelectedValue; objusercar.Status = CheckBox1.Text; if (CheckBox1.Checked == true) { objusercar.Status = "Active"; } else { objusercar.Status = "Inactive"; } objusercar.InsertData(objusercar); /*if (Request.QueryString["action"] == "add") * { * * } * else if (Request.QueryString["action"] == "edit") * { * objusercar.UpdateData(objusercar, txtuccode.Text); * }*/ } catch (Exception x) { } }