public void DeleteCaffeBillsTest()
        {
            bir.InsertCaffeBill(cb);
            CaffeBill c      = bir.GetCaffeBills().Where(x => x.Total_Price == cb.Total_Price).ToList()[0];
            int       result = bir.DeleteCaffeBill(c.Bill_ID);

            bir.InsertCaffeBill(cb);
            Assert.IsTrue(result > 0);
        }
        public void UpdateCaffeBillsTest()
        {
            bir.InsertCaffeBill(cb);
            CaffeBill c = bir.GetCaffeBills().Where(x => x.Total_Price == cb.Total_Price).ToList()[0];

            c.Paid = false;
            int result = bir.UpdateCaffeBill(c);

            Assert.IsTrue(result > 0);
        }
Пример #3
0
        public bool UpdateCaffeBill(CaffeBill caffeBill)
        {
            int result = this.billRepository.UpdateCaffeBill(caffeBill);

            if (result != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public int InsertCaffeBill(CaffeBill caffeBill)
        {
            int result;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection   = connection;
                caffeBill.Date_And_Time = DateTime.Now;
                sqlCommand.CommandText  = $"Insert into Bills( Table_ID, Total_Price, Date_And_Time, Paid) values({caffeBill.Table_ID},{caffeBill.Total_Price},'{caffeBill.Date_And_Time.ToString("MM/dd/yyyy HH:mm:ss")}',0)";
                result = sqlCommand.ExecuteNonQuery();
            }
            return(result);
        }
        public int UpdateCaffeBill(CaffeBill caffeBill)
        {
            int result;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection  = connection;
                sqlCommand.CommandText = "Update Bills SET Table_ID =@tableID, Total_Price = @totalPrice, Date_And_Time = @dateAndTime, Paid = @Paid where Bill_ID = @billID";
                sqlCommand.Parameters.AddWithValue("@tableID", caffeBill.Table_ID);
                sqlCommand.Parameters.AddWithValue("@totalPrice", caffeBill.Total_Price);
                sqlCommand.Parameters.AddWithValue("@dateAndTime", caffeBill.Date_And_Time);
                sqlCommand.Parameters.AddWithValue("@billID", caffeBill.Bill_ID);
                sqlCommand.Parameters.AddWithValue("@Paid", caffeBill.Paid);
                result = sqlCommand.ExecuteNonQuery();
            }
            return(result);
        }
        public void clean()
        {
            CaffeBill c = bir.GetCaffeBills().Where(x => x.Total_Price == cb.Total_Price).ToList()[0];

            bir.DeleteCaffeBill(c.Bill_ID);
        }
 public void init()
 {
     cb  = new CaffeBill(9999, 1, 98765, DateTime.Now, true);
     bir = new BillRepository();
 }