public bool Insert(BillServiceInfo billServiceInfo) { try { OpenConnection(); string queryString = "INSERT INTO BillServiceInfo(idBillService, idService,price,tips, quantity,paidMoney,status,deliveryDate) VALUES(@idBillService, @idService,@price,@tips, @quantity, @paidMoney, @status,@deliveryDate)"; MySqlCommand command = new MySqlCommand(queryString, conn); command.Parameters.AddWithValue("@idBillService", billServiceInfo.IdBillService); command.Parameters.AddWithValue("@idService", billServiceInfo.IdService); command.Parameters.AddWithValue("@price", billServiceInfo.Price); command.Parameters.AddWithValue("@tips", billServiceInfo.Tips); command.Parameters.AddWithValue("@quantity", billServiceInfo.Quantity); command.Parameters.AddWithValue("@paidMoney", billServiceInfo.PaidMoney); command.Parameters.AddWithValue("@status", billServiceInfo.Status); command.Parameters.AddWithValue("@deliveryDate", billServiceInfo.DeliveryDate); command.ExecuteNonQuery(); return(true); } catch { return(false); } finally { CloseConnection(); } }
public BillServiceInfo GetBillServiceInfo(string idBillService, string idService) { try { OpenConnection(); string queryString = "SELECT * FROM BillServiceInfo WHERE idBillService=@idBillService AND idService=@idService;"; MySqlCommand command = new MySqlCommand(queryString, conn); command.Parameters.AddWithValue("@idBillService", idBillService); command.Parameters.AddWithValue("@idService", idService); int rs = command.ExecuteNonQuery(); MySqlDataAdapter adapter = new MySqlDataAdapter(command); DataTable dataTable = new DataTable(); adapter.Fill(dataTable); BillServiceInfo billInfo = new BillServiceInfo(int.Parse(dataTable.Rows[0].ItemArray[0].ToString()), int.Parse(dataTable.Rows[0].ItemArray[1].ToString()), float.Parse(dataTable.Rows[0].ItemArray[2].ToString()), float.Parse(dataTable.Rows[0].ItemArray[3].ToString()), int.Parse(dataTable.Rows[0].ItemArray[4].ToString()), float.Parse(dataTable.Rows[0].ItemArray[5].ToString()), int.Parse(dataTable.Rows[0].ItemArray[6].ToString()), DateTime.Parse(dataTable.Rows[0].ItemArray[7].ToString())); return(billInfo); } catch { return(new BillServiceInfo()); } finally { CloseConnection(); } }
public bool Update(BillServiceInfo billServiceInfo) { try { OpenConnection(); string queryString = "UPDATE BillServiceInfo SET quantity=@quantity,paidMoney=@paidMoney,status=@status,deliveryDate=@deliveryDate where idService=@idService and idBillService=@idBillService"; MySqlCommand command = new MySqlCommand(queryString, conn); command.Parameters.AddWithValue("@idService", billServiceInfo.IdService.ToString()); command.Parameters.AddWithValue("@idBillService", billServiceInfo.IdBillService.ToString()); command.Parameters.AddWithValue("@quantity", billServiceInfo.Quantity.ToString()); command.Parameters.AddWithValue("@paidMoney", billServiceInfo.PaidMoney); command.Parameters.AddWithValue("@status", billServiceInfo.Status); command.Parameters.AddWithValue("@deliveryDate", billServiceInfo.DeliveryDate.ToString("yyyy-MM-dd")); command.ExecuteNonQuery(); return(true); } catch { return(false); } finally { CloseConnection(); } }
public List <BillServiceInfo> GetBillServiceInfos(string idBillService) { List <BillServiceInfo> billInfos = new List <BillServiceInfo>(); try { OpenConnection(); string queryString = "SELECT * FROM BillServiceInfo WHERE idBillService=" + idBillService; MySqlCommand command = new MySqlCommand(queryString, conn); command.ExecuteNonQuery(); MySqlDataAdapter adapter = new MySqlDataAdapter(command); DataTable dataTable = new DataTable(); adapter.Fill(dataTable); for (int i = 0; i < dataTable.Rows.Count; i++) { BillServiceInfo billInfo = new BillServiceInfo(int.Parse(dataTable.Rows[i].ItemArray[0].ToString()), int.Parse(dataTable.Rows[i].ItemArray[1].ToString()), float.Parse(dataTable.Rows[i].ItemArray[2].ToString()), float.Parse(dataTable.Rows[i].ItemArray[3].ToString()), int.Parse(dataTable.Rows[i].ItemArray[4].ToString()), float.Parse(dataTable.Rows[i].ItemArray[5].ToString()), int.Parse(dataTable.Rows[i].ItemArray[6].ToString()), DateTime.Parse(dataTable.Rows[i].ItemArray[7].ToString())); billInfos.Add(billInfo); } return(billInfos); } catch { return(billInfos); } finally { CloseConnection(); } }
public void ConfirmDeliveried(BillServiceTemplateControl billServiceTemplateControl) { BillServiceInfo billServiceInfo = BillServiceInfoDAL.Instance.GetBillServiceInfo(ConvertToIDString(checkedItem.txbId.Text), billServiceTemplateControl.txbIdService.Text); billServiceInfo.DeliveryDate = DateTime.Now; billServiceInfo.Status = 1; //billServiceInfo.PaidMoney = (billServiceInfo.Price + billServiceInfo.Tips) * billServiceInfo.Quantity; if (BillServiceInfoDAL.Instance.Update(billServiceInfo)) { CustomMessageBox.Show("Cập nhật giao hàng thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Asterisk); Customer customer = CustomerDAL.Instance.FindById(checkedItem.txbIdCustomer.Text); UpdateMembership(customer, ConvertToNumber(billServiceTemplateControl.txbRest.Text)); checkedItem.btnDeleteBillService.Visibility = Visibility.Hidden; checkedItem.txbRest.Text = main.txbRestBS.Text = (double.Parse(main.txbRestBS.Text) - double.Parse(billServiceTemplateControl.txbRest.Text)).ToString(); billServiceTemplateControl.txbRest.Text = "0"; billServiceTemplateControl.txbStatus.Text = "Đã giao"; billServiceTemplateControl.txbDeliveryDate.Text = DateTime.Now.ToShortDateString(); billServiceTemplateControl.btnSwapStatus.IsHitTestVisible = false; billServiceTemplateControl.btnSwapStatus.Visibility = Visibility.Hidden; billServiceTemplateControl.txbStatus.Foreground = (System.Windows.Media.Brush) new BrushConverter().ConvertFrom("#FF01B500"); if (BillServiceInfoDAL.Instance.IsFullDeliveried(ConvertToIDString(checkedItem.txbId.Text))) { BillService billService = BillServiceDAL.Instance.GetBillService(ConvertToIDString(checkedItem.txbId.Text)); billService.Status = 1; if (BillServiceDAL.Instance.Update(billService)) { checkedItem.txbStatus.Text = "Đã giao"; checkedItem.txbStatus.Foreground = (System.Windows.Media.Brush) new BrushConverter().ConvertFrom("#FF01B500"); } } } else { CustomMessageBox.Show("Cập nhật thất bại!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error); } //billServiceTemplateControl.icStatus.Kind = MaterialDesignThemes.Wpf.PackIconKind.TickCircleOutline; //billServiceTemplateControl.btnSwapStatus.Foreground = (System.Windows.Media.Brush)new BrushConverter().ConvertFrom("#FF01B500"); }