public bool Delete(Cus cus) { bool isDelete = false; try { SqlConnection sqlConnection = new SqlConnection(connectionString); string commandString = "DELETE FROM Customer WHERE Name = '" + cus.Name + "'"; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); sqlConnection.Open(); int isExecute = sqlCommand.ExecuteNonQuery(); if (isExecute > 0) { isDelete = true; } sqlConnection.Close(); } catch (Exception excp) { // MessageBox.Show(excp.Message); } return(isDelete); }
public bool Add(Cus cus) { bool isAdded = false; try { SqlConnection sqlConnection = new SqlConnection(connectionString); string commandString = "INSERT INTO Customer (Code,Name, Contact, Address, District) VALUES('" + cus.Code + "', '" + cus.Name + "', '" + cus.Contact + "', '" + cus.Address + "', '" + cus.District + "')"; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); sqlConnection.Open(); int isExecute = sqlCommand.ExecuteNonQuery(); if (isExecute > 0) { isAdded = true; } sqlConnection.Close(); } catch (Exception exception) { // MessageBox.Show(excp.Message); } return(isAdded); }
static void Main(string[] args) { Cus customer = new Cus(); Console.OutputEncoding = System.Text.Encoding.Unicode; Console.InputEncoding = System.Text.Encoding.Unicode; Console.Write("Enter name: "); customer.name = Console.ReadLine(); int a; Console.Clear(); Console.WriteLine("1. Grocery Items\n2. Bakery Products"); Console.Write("Enter your choice: "); a = Convert.ToInt32(Console.ReadLine()); switch (a) { case 1: Grocery grocery = new Grocery(); Console.WriteLine("Your name: " + customer.name); Console.WriteLine(grocery.ToString()); break; case 2: Bakery bakery = new Bakery(); Console.WriteLine("Your name: " + customer.name); Console.WriteLine(bakery.ToString()); break; default: break; } }
public IActionResult Create([FromBody] Cus cus) { if (ModelState.IsValid) { dataAccessProvider.AddPatientRecord(cus); return(Ok()); } return(BadRequest()); }
public List <CartDet> ListCartPreview() { try { Cus cus = _cusBus.GetAll().FirstOrDefault(m => m.CusId == (WebSession.LoginUsr as Usr)?.UsrId); Cart cart = _cartBus.GetAll().FirstOrDefault(m => cus != null && m.CusId == cus.CusId); if (cart == null && cus != null) { cart = new Cart() { CusId = cus.CusId }; _cartBus.Insert(cart); cart = _cartBus.GetAll().FirstOrDefault(m => cus != null && m.CusId == cus.CusId); } return(GetAll().Where(m => cart != null && m.CartId == cart.CartId).ToList()); } catch { return(null); } }
public bool IsNameExist(Cus cus) { bool isExist = false; SqlConnection sqlConnection = new SqlConnection(connectionString); string commandString = @"SELECT Name,Contact,Address FROM Customer WHERE Name = '" + cus.Name + "' "; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); DataTable dataTable = new DataTable(); int isFill = sqlDataAdapter.Fill(dataTable); if (isFill > 0) { isExist = true; } return(isExist); }
private void TripOrderForm_Load(object sender, EventArgs e) { #region ComboBox1 XmlDocument xmlCustomersDoc = new XmlDocument(); xmlCustomersDoc.Load(xmlCustomersFile); var itemNodes = xmlCustomersDoc.SelectNodes("Customers"); int i = 0; int arrayLength = 0; foreach (XmlNode node in itemNodes) { var Customer = node.SelectNodes("Customer"); foreach (XmlNode Cus in Customer) { arrayLength++; } } string[] ID = new string[arrayLength]; string[] FirstName = new string[arrayLength]; string[] LastName = new string[arrayLength]; foreach (XmlNode node in itemNodes) { var Customer = node.SelectNodes("Customer"); foreach (XmlNode Cus in Customer) { ID[i] = Cus.SelectSingleNode("ID").InnerText; FirstName[i] = Cus.SelectSingleNode("FirstName").InnerText; LastName[i] = Cus.SelectSingleNode("LastName").InnerText; i++; } } for (int j = 0; j < arrayLength; j++) { UserComboBoxData item = new UserComboBoxData(FirstName[j] + " " + LastName[j], int.Parse(ID[j])); this.comboBox1.Items.Add(item); } this.comboBox1.SelectedIndex = 0; #endregion #region ComboBox2 XmlDocument xmlDriversDoc = new XmlDocument(); xmlDriversDoc.Load(xmlDriversFile); var itemNodes2 = xmlDriversDoc.SelectNodes("Drivers"); int i2 = 0; int arrayLength2 = 0; foreach (XmlNode node in itemNodes2) { var Customer = node.SelectNodes("Driver"); foreach (XmlNode Cus in Customer) { arrayLength2++; } } string[] ID2 = new string[arrayLength2]; string[] FirstName2 = new string[arrayLength2]; string[] LastName2 = new string[arrayLength2]; foreach (XmlNode node in itemNodes2) { var Driver = node.SelectNodes("Driver"); foreach (XmlNode Cus in Driver) { ID2[i2] = Cus.SelectSingleNode("ID").InnerText; FirstName2[i2] = Cus.SelectSingleNode("FirstName").InnerText; LastName2[i2] = Cus.SelectSingleNode("LastName").InnerText; i2++; } } for (int j = 0; j < arrayLength2; j++) { UserComboBoxData item = new UserComboBoxData(FirstName2[j] + " " + LastName2[j], int.Parse(ID2[j])); this.comboBox2.Items.Add(item); } this.comboBox2.SelectedIndex = 0; #endregion #region ComboBox3 XmlDocument xmlReservationPersonDoc = new XmlDocument(); xmlReservationPersonDoc.Load(xmlReservationPersonFile); var itemNodes3 = xmlReservationPersonDoc.SelectNodes("ReservationPersons"); int i3 = 0; int arrayLength3 = 0; foreach (XmlNode node in itemNodes3) { var ReservationPerson = node.SelectNodes("ReservationPerson"); foreach (XmlNode Cus in ReservationPerson) { arrayLength3++; } } string[] ID3 = new string[arrayLength3]; string[] FirstName3 = new string[arrayLength3]; string[] LastName3 = new string[arrayLength3]; foreach (XmlNode node in itemNodes3) { var ReservationPerson = node.SelectNodes("ReservationPerson"); foreach (XmlNode Cus in ReservationPerson) { ID3[i3] = Cus.SelectSingleNode("ID").InnerText; FirstName3[i3] = Cus.SelectSingleNode("FirstName").InnerText; LastName3[i3] = Cus.SelectSingleNode("LastName").InnerText; i3++; } } for (int j = 0; j < arrayLength3; j++) { UserComboBoxData item = new UserComboBoxData(FirstName3[j] + " " + LastName3[j], int.Parse(ID3[j])); this.comboBox3.Items.Add(item); } this.comboBox3.SelectedIndex = 0; #endregion }
public Cart GetMyCart() { Cus cus = WebSession.LoginCus; return(MyLibrary.Cart_BUS.GetAll().FirstOrDefault(m => cus != null && m.CusId == cus.CusId)); }
public bool Delete(Cus cus) { return(_customerRepository.Delete(cus)); }
public bool IsNameExist(Cus cus) { return(_customerRepository.IsNameExist(cus)); }
public bool Add(Cus cus) { return(_customerRepository.Add(cus)); }
//更新订单 public void update(string name, string phoneNum) { Cus.update(name, phoneNum); }