/// <summary> /// 根据ID查看一条详细信息 /// </summary> /// <param name="c_Id"></param> /// <returns></returns> public Cheer getCheerById(int c_Id) { string sql = "pro_getCheerById"; Cheer cheer = null; SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@C_Id", c_Id) }; using (SqlDataReader reader = DBHelper.ExecuteReaderProc(sql, parms)) { if (reader.Read()) { cheer = new Cheer(); cheer.BillPhoto = (string)reader["BillPhoto"]; cheer.C_CarType = (string)reader["C_CarType"]; cheer.C_CheerType = (string)reader["C_CheerType"]; cheer.C_Date = (DateTime)reader["C_Date"]; cheer.C_Id = (int)reader["C_Id"]; cheer.C_Station = (string)reader["C_Station"]; cheer.C_Sum = Convert.ToDouble(reader["C_Sum"]); cheer.Remark = (string)reader["Remark"]; cheer.CarMark = (string)reader["CarMark"]; } reader.Close(); } return(cheer); }
/// <summary> /// 按条件查询加油记录 /// </summary> /// <param name="statime"></param> /// <param name="endtime"></param> /// <param name="c_CarType"></param> /// <param name="c_Station"></para /// <returns></returns> public IList <Cheer> getAllCheer(string statime, string endtime, string c_CarType, string c_Station) { IList <Cheer> list = new List <Cheer>(); string sql = "prc_getAllCheer"; SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@Statime", statime), new SqlParameter("@Endtime", endtime), new SqlParameter("@C_CarType", c_CarType), new SqlParameter("@C_Station", c_Station) }; using (SqlDataReader reader = DBHelper.ExecuteReaderProc(sql, parms)) { while (reader.Read()) { Cheer cheer = new Cheer(); cheer.BillPhoto = (string)reader["BillPhoto"]; cheer.C_CarType = (string)reader["C_CarType"]; cheer.C_CheerType = (string)reader["C_CheerType"]; cheer.C_Date = (DateTime)reader["C_Date"]; cheer.C_Id = (int)reader["C_Id"]; cheer.C_Station = (string)reader["C_Station"]; cheer.C_Sum = Convert.ToDouble(reader["C_Sum"]); cheer.CarMark = (string)reader["CarMark"]; cheer.Remark = (string)reader["Remark"]; list.Add(cheer); } reader.Close(); } return(list); }
/// <summary> /// 更新一条信息 /// </summary> /// <param name="ch"></param> public static int updateCheer(Cheer ch) { try { return(CheerService.updateCheer(ch)); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
/// <summary> /// 查询所有的加油厂 /// </summary> /// <returns></returns> public IList <Cheer> getCheerStation() { IList <Cheer> list = new List <Cheer>(); string sql = "prc_getCheerStation"; using (SqlDataReader reader = DBHelper.ExecuteReaderProc(sql, null)) { while (reader.Read()) { Cheer cheer = new Cheer(); cheer.C_Station = (string)reader["C_Station"]; list.Add(cheer); } reader.Close(); } return(list); }
/// <summary> /// 添加一条信息 /// </summary> /// <param name="ch"></param> public int addCheer(Cheer ch) { string sql = "pro_AddCheer"; SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@BillPhoto", ch.BillPhoto), new SqlParameter("@C_CarType", ch.C_CarType), new SqlParameter("@C_CheerType", ch.C_CheerType), new SqlParameter("@C_Date", ch.C_Date), new SqlParameter("@C_Id", ch.C_Id), new SqlParameter("@C_Station", ch.C_Station), new SqlParameter("@C_Sum", ch.C_Sum), new SqlParameter("@CarMark", ch.CarMark), new SqlParameter("@Remark", ch.Remark) }; int result = DBHelper.ExecuteNonQueryProc(sql, parms); return(result); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { rblCarType.Enabled = true; ddlCarMark.Enabled = true; int C_Id = 1; string name = "0"; C_Id = Convert.ToInt32(Request.QueryString["C_Id"]); name = Request.QueryString["C_name"]; if (C_Id != 0) { Cheer ch = CheerManager.getCheerById(C_Id); ddlCarMark.DataSourceID = null; ddlCarMark.DataSource = CarsManager.GetAllCars(); ddlCarMark.DataTextField = "CarMark"; ddlCarMark.DataValueField = "Car_Id"; ddlCarMark.DataBind(); ddlCarMark.SelectedItem.Text = ch.CarMark; ddlCheerType.SelectedValue = ch.C_CheerType; txtCheerDate.Value = ch.C_Date.ToShortDateString(); txtMoney.Text = ch.C_Sum.ToString(); txtStation.Text = ch.C_Station; rblCarType.SelectedValue = ch.C_CarType; txtRemark.Value = ch.Remark; image.ImageUrl = ch.BillPhoto; } if (name == "Up") { rblCarType.Enabled = false; ddlCarMark.Enabled = false; } //else //{ // rblCarType.Enabled = false; //} } }
static void Main(string[] args) { //Overloaded Constructor. For example to write out the customers name that they put in before this. For this example I put in a name. var customer = new Customer("Greta", "Garbo"); System.Console.WriteLine("Welcome {0} {1}.", customer.Name, customer.LastName); System.Console.WriteLine("What item do you wish to put in your shopping-bag, {0}?", customer.FullName); Console.WriteLine(" "); // This is a while loop that makes alternatives to put in your shopping-bag. while (true) { Console.WriteLine("1. Coutch"); Console.WriteLine("2. Chair"); Console.WriteLine("3. Bed"); Console.WriteLine(" "); Int32 answer = Int32.Parse(Console.ReadKey(true).KeyChar.ToString()); Shop shop = Factory.getShop(answer); Console.WriteLine("Choose a color on your " + shop.Item + ":"); Console.Write("1."); Console.WriteLine(ChooseColor.black); Console.Write("2."); Console.WriteLine(ChooseColor.white); //using enum to make it easier for me to write out the colors for the customer to choose from. Console.Write("3."); Console.WriteLine(ChooseColor.beige); Console.WriteLine(" "); answer = Int32.Parse(Console.ReadKey(true).KeyChar.ToString()); shop.getShop(answer); Console.WriteLine(" "); Console.WriteLine("Your shopping-bag is full. Your order will arrive soon."); Console.WriteLine("Press any key to exit."); Console.ReadKey(); break; } //I decide to use polymorphism so that i can use the same code on all the orderd objects. var cheer = new Cheer(); cheer.Kassa(); var table = new Table(); table.Kassa(); Kassa_Polymorphism kassa_polymorphism = cheer; kassa_polymorphism.Kassa(); // and so on if you want to add some more objects with this function. }
protected void btnSave_Click(object sender, EventArgs e) { string name = "0"; name = Request.QueryString["C_name"]; Cheer ch = new Cheer(); ch.C_Id = Convert.ToInt32(Request.QueryString["C_Id"]); string FileName = System.IO.Path.GetFileName(fuBillPhoto.PostedFile.FileName).ToLower(); if (!string.IsNullOrEmpty(FileName)) { fuBillPhoto.PostedFile.SaveAs(Server.MapPath("~/images/UpLoad/" + FileName)); ch.BillPhoto = "~/images/UpLoad/" + FileName; } else { ch.BillPhoto = ""; } image.ImageUrl = ch.BillPhoto; ch.C_CarType = rblCarType.SelectedValue; ch.C_CheerType = ddlCheerType.SelectedValue; ch.C_Date = Convert.ToDateTime(txtCheerDate.Value); ch.C_Station = txtStation.Text; ch.C_Sum = Convert.ToDouble(txtMoney.Text); ch.Remark = txtRemark.Value; ch.CarMark = ddlCarMark.SelectedItem.Text; if (ddlCarMark.SelectedItem.Text == "请选择") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择正确的车牌号!');", true); return; } if (name == "Up") { int result = CheerManager.updateCheer(ch); if (result != 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新成功!');window.location.href='Cheerlist.aspx'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新失败!');", true); txtCheerDate.Value = ""; txtStation.Text = ""; txtMoney.Text = ""; txtRemark.Value = ""; return; } } else { int result = CheerManager.addCheer(ch); if (result != 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功!');window.location.href='Cheerlist.aspx'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!');", true); txtCheerDate.Value = ""; txtStation.Text = ""; txtMoney.Text = ""; txtRemark.Value = ""; return; } } }