private void buttonAdd_Click(object sender, EventArgs e) { if (!CheckData()) { return; } CustomerBean c = new CustomerBean(); c.Name = customer; c.Phone = phone; c.Sex = sex; c.IdCard = idCard; c.Email = email; c.Address = address; c.Remark = remark; c.Age = age; MD5 md5 = MD5.Create(); byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(passwd)); c.Password = Convert.ToBase64String(s); c.Baby = student; c.BabyAge = age; c.Relation = relation; CustomerDAO dao = new CustomerDAO(); if (dao.FindCustomer(c) == false) { dao.AddCustomer(c); } }
private void buttonUpdate_Click(object sender, EventArgs e) { if (!CheckData()) { return; } CustomerBean c = new CustomerBean(); c.Name = customer; c.Phone = phone; c.Sex = sex; c.IdCard = idCard; c.Email = email; c.Address = address; c.Remark = remark; c.Age = age; c.Baby = student; c.BabyAge = age; c.Relation = relation; CustomerDAO dao = new CustomerDAO(); dao.UpdateCustomer(c); }
private void SaveEnroll() { OrderBean o = new OrderBean(); ItemReserveBean item; float discount = 0; float total = 0; CustomerBean c = new CustomerBean(); c.Id = customerId; foreach (DataRow varRow in tabSelect.Rows) { item = new ItemReserveBean(); item.Count = Convert.ToInt32(varRow["Count"].ToString()); item.Lesson.Id = Convert.ToInt32(varRow["Id"].ToString()); item.PriceDiscount = (float)Convert.ToDouble(varRow["PriceDiscount"].ToString()); item.PriceTotal = (float)Convert.ToDouble(varRow["PriceReal"].ToString()); item.Order = o; o.Items.Add(item); discount += item.PriceDiscount; total += item.PriceTotal; } o.PriceTotal = total; o.PriceDiscount = discount; o.Customer = c; OrderDAO d = new OrderDAO(); d.AddOrder(o); }
public int UpdateCustomer(CustomerBean b) { int count = 0; try { SqlParameter[] sp = { para = new SqlParameter("@Id", b.Id), para = new SqlParameter("@Name", b.Name), para = new SqlParameter("@Phone", b.Phone), para = new SqlParameter("@IdCard", b.IdCard), para = new SqlParameter("@Address", b.Address), para = new SqlParameter("@Email", b.Email), para = new SqlParameter("@ChatId", b.ChatId), para = new SqlParameter("@Remark", b.Remark), para = new SqlParameter("@BabyName", b.Baby), para = new SqlParameter("@BabyAge", b.BabyAge), para = new SqlParameter("@Relation", b.Relation), }; count = sh.RunSql("PR_Customer_Update", sp); } catch (Exception ex) { throw ex; } return(count); }
private SqlParameter para; //参数 public int AddCustomer(CustomerBean b) { int count = 0; try { SqlParameter[] sp = { para = new SqlParameter("@Id", SqlDbType.Int), para = new SqlParameter("@Name", b.Name), para = new SqlParameter("@Phone", b.Phone), para = new SqlParameter("@IdCard", b.IdCard), para = new SqlParameter("@Password", b.Password), para = new SqlParameter("@Sex", b.Sex), para = new SqlParameter("@Email", b.Email), para = new SqlParameter("@ChatId", b.ChatId), para = new SqlParameter("@Address", b.Address), para = new SqlParameter("@BabyName", b.Baby), para = new SqlParameter("@BabyAge", b.BabyAge), para = new SqlParameter("@Relation", b.Relation), para = new SqlParameter("@Remark", b.Remark), }; sp[0].Direction = ParameterDirection.Output; count = sh.RunSql("PR_Customer_Add", sp); b.Id = Convert.ToInt32(sp[0].Value.ToString()); } catch (Exception ex) { throw ex; } return(count); }
public LessonConsumeConfirmForm(CustomerBean b, DataTable tabSelect) { InitializeComponent(); gridCtrl.DataSource = tabSelect; textEditCustomer.Text = b.Name; textEditPhone.Text = b.Phone; textEditIdCard.Text = b.IdCard; }
public bool DeleteCustomer(CustomerBean b) { try { SqlParameter[] sp = { para = new SqlParameter("@Id", b.Id), }; ds = sh.GetDataSet("PR_Customer_Delete", sp); } catch (Exception ex) { throw ex; } return(ds.Tables[0].Rows.Count > 0); }
private void simpleButtonSubmit_Click(object sender, EventArgs e) { if (!CheckData()) { return; } CustomerBean b = new CustomerBean(); b.Name = textEditCustomer.Text; b.Phone = textEditPhone.Text; b.IdCard = textEditIdCard.Text; LessonConsumeConfirmForm f = new LessonConsumeConfirmForm(b, tabSelect); if (f.ShowDialog() == DialogResult.OK) { SaveConsume(); } }
private void fillCustomers() { try { string selectedCompVal = lst_cust_grp.SelectedItem.Value; string sql = " SELECT * from pos.tcustomer where GRP_ID=@grp_id"; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("@grp_id", selectedCompVal); List <CustomerBean> customerDataSource = new CustomerBean().getAllCustomer(sql, parameters); lst_customer.DataSource = customerDataSource; lst_customer.DataTextField = "NAME"; lst_customer.DataValueField = "ID"; lst_customer.DataBind(); } catch (Exception ex) { MyLog.Error(ex); } }
public bool FindCustomer(CustomerBean b) { try { SqlParameter[] sp = { para = new SqlParameter("@Name", b.Name), para = new SqlParameter("@Phone", b.Phone), }; ds = sh.GetDataSet("PR_Customer_Find", sp); if (ds.Tables[0].Rows.Count > 0) { b.Id = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"].ToString()); } } catch (Exception ex) { throw ex; } return(ds.Tables[0].Rows.Count > 0); }