public ActionResult Index(Customer wes) { var littleBunny = new CustomerInf(); if (ModelState.IsValid) { using (wenevaescapeEntities littleCat = new wenevaescapeEntities()) { //if (littleCat.CustomerInfs.Any(x => x.Name == wes.Name && x.Phone == wes.Phone && x.Email == wes.Email)) //{ // ModelState.AddModelError("", "Khách hàng này đã có trong danh sách"); // return View("Index", wes); //} //else //{ littleBunny.Name = wes.Name; littleBunny.Email = wes.Email; littleBunny.Phone = wes.Phone; littleBunny.DoB = wes.DoB; littleBunny.Address = wes.Address; littleBunny.PreCode = wes.PreCode; littleBunny.Month = DateTime.Now.ToString("MM"); littleBunny.Year = DateTime.Now.ToString("yyyy"); littleBunny.Days = DateTime.Now.Day.ToString(); littleCat.CustomerInfs.Add(littleBunny); littleCat.SaveChanges(); //} ViewBag.SuccessMessage = "Đã thêm khách hàng"; } ModelState.Clear(); } return(View("Index", new Customer())); }
private void btnConfirm_Click_1(object sender, EventArgs e) { if (txtname.Text == "") { MessageBox.Show("Cannot Empty"); } else if (cmbsex.Text == "") { MessageBox.Show("Cannot Empty"); } else if (cmbtype.Text == "") { MessageBox.Show("Cannot Empty"); } else if (cmbID.Text == "") { MessageBox.Show("Cannot Empty"); } else if (txtpr.Text == "") { MessageBox.Show("Cannot Empty"); } else if (txtroompr.Text == "") { MessageBox.Show("Cannot Empty"); } else if (txtphone.Text == "") { MessageBox.Show("Cannot Empty"); } else if (txtcardid.Text == "") { MessageBox.Show("Cannot Empty"); } else if (txtphone.Text == "") { MessageBox.Show("Cannot Empty"); } else if (txtcardid.Text == "") { MessageBox.Show("Cannot Empty"); } else { CustomerInf sti = new CustomerInf(); sti.Name = txtname.Text.Trim().ToString(); sti.Sex = cmbsex.SelectedItem.ToString(); sti.Id = Convert.ToInt32(cmbID.SelectedItem.ToString()); sti.Amoney = Convert.ToInt32(txtpr.Text); sti.Moeny = Convert.ToInt32(txtroompr.Text); sti.Phone = txtphone.Text.Trim().ToString(); sti.Cardid = txtcardid.Text.Trim().ToString(); sti.DaoqTime = dateTimePicker1.Text.ToString(); sti.Notes = txtinf.Text.Trim().ToString(); bool v = BLL.CustomerBLL.BllSelectNullRoom(sti); bool insertroom = BLL.CustomerBLL.BllinsertRoom(Convert.ToInt32(txtroompr.Text), Convert.ToInt32(cmbID.SelectedItem.ToString())); if (v) { MessageBox.Show("Create Successful...."); } ds = BLL.CustomerBLL.BllSelect(); dataGridView1.DataSource = ds.Tables[0]; } ////ds = BLL.CustomerBLL.BllSelect(); ////rows(); //dataGridView1.DataSource = ds.Tables[0]; }
public static bool DalSelectNullRoom(CustomerInf sti) { StringBuilder strber = new StringBuilder(); strber.Append("insert into Customer values(@C_name,@C_sex,@R_id,@C_AllMoney,@C_money,@C_Phone,@C_cardid,default,@C_daoqtime,@C_notes)"); SqlParameter Name = new SqlParameter(); Name.ParameterName = "@C_name"; Name.SqlDbType = SqlDbType.NVarChar; Name.Size = 20; Name.Value = sti.Name; SqlParameter Sex = new SqlParameter(); Sex.ParameterName = "@C_sex"; Sex.SqlDbType = SqlDbType.NVarChar; Sex.Size = 2; Sex.Value = sti.Sex; SqlParameter id = new SqlParameter(); id.ParameterName = "@R_id"; id.SqlDbType = SqlDbType.Int; id.Value = sti.Id; SqlParameter allmoney = new SqlParameter(); allmoney.ParameterName = "@C_AllMoney"; allmoney.SqlDbType = SqlDbType.Money; allmoney.Value = sti.Amoney; SqlParameter money = new SqlParameter(); money.ParameterName = "@C_money"; money.SqlDbType = SqlDbType.Money; money.Value = sti.Moeny; SqlParameter Phone = new SqlParameter(); Phone.ParameterName = "@C_Phone"; Phone.SqlDbType = SqlDbType.NChar; Phone.Size = 11; Phone.Value = sti.Phone; SqlParameter Cardid = new SqlParameter(); Cardid.ParameterName = "@C_cardid"; Cardid.SqlDbType = SqlDbType.NVarChar; Cardid.Size = 18; Cardid.Value = sti.Cardid; SqlParameter daoqtime = new SqlParameter(); daoqtime.ParameterName = "@C_daoqtime"; daoqtime.SqlDbType = SqlDbType.DateTime; daoqtime.Value = Convert.ToDateTime(sti.DaoqTime); SqlParameter notse = new SqlParameter(); notse.ParameterName = "@C_notes"; notse.SqlDbType = SqlDbType.NVarChar; notse.Size = 50; notse.Value = sti.Notes; return(SqlHelper.CustomerHelper.HelperInsert(strber.ToString(), new SqlParameter[] { Name, Sex, id, allmoney, money, Phone, Cardid, daoqtime, notse })); }
public static bool BllSelectNullRoom(CustomerInf sti) { return(DAL.CustomerDAL.DalSelectNullRoom(sti)); }