public int ReprintBill(int OrderBillID) { Printer.PrintBill.Print(OrderBillID, true); OrderBill bill = new OrderBill(); return bill.OrderBillPrint(OrderBillID); }
public string SendOrderBill(OrderBill Bill) { if ((Bill == null) || Bill.BillID.Equals(null)) { return "No data"; } SqlConnection connection = null; SqlTransaction transaction = null; try { connection = ConnectDB.GetConnection(); transaction = connection.BeginTransaction(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.Transaction = transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "updateOrderBill"; command.Parameters.Add("@orderBillID", SqlDbType.Int).Value = Bill.OrderBillID; command.Parameters.Add("@billID", SqlDbType.Int).Value = Bill.BillID; command.Parameters.Add("@employeeID", SqlDbType.Int).Value = Bill.EmployeeID; SqlParameter parameter4 = command.Parameters.Add("@closeBillDate", SqlDbType.DateTime); if (Bill.CloseBillDate.CompareTo(AppParameter.MinDateTime) <= 0) { parameter4.Value = DBNull.Value; } else { parameter4.Value = Bill.CloseBillDate; } SqlParameter parameter5 = command.Parameters.Add("@result", SqlDbType.Int); parameter5.Direction = ParameterDirection.Output; command.ExecuteNonQuery(); if (((int) parameter5.Value) == 0) { transaction.Rollback(); return "Can't update order bill"; } if (Bill.Items != null) { SqlCommand command2 = new SqlCommand(); command2.Connection = connection; command2.Transaction = transaction; command2.CommandType = CommandType.StoredProcedure; SqlParameter parameter6 = command2.Parameters.Add("@billDetailID", SqlDbType.Int); SqlParameter parameter7 = command2.Parameters.Add("@orderBillID", SqlDbType.Int); SqlParameter parameter8 = command2.Parameters.Add("@menuID", SqlDbType.Int); SqlParameter parameter9 = command2.Parameters.Add("@unit", SqlDbType.Int); SqlParameter parameter10 = command2.Parameters.Add("@status", SqlDbType.TinyInt); SqlParameter parameter11 = command2.Parameters.Add("@message", SqlDbType.NText); SqlParameter parameter12 = command2.Parameters.Add("@serveTime", SqlDbType.DateTime); SqlParameter parameter13 = command2.Parameters.Add("@cancelReasonID", SqlDbType.Int); SqlParameter parameter14 = command2.Parameters.Add("@employeeID", SqlDbType.Int); SqlParameter parameter15 = command2.Parameters.Add("@result", SqlDbType.Int); parameter15.Direction = ParameterDirection.Output; SqlCommand command3 = new SqlCommand(); command3.Connection = connection; command3.Transaction = transaction; command3.CommandType = CommandType.StoredProcedure; SqlParameter parameter16 = command3.Parameters.Add("@billDetailID", SqlDbType.Int); SqlParameter parameter17 = command3.Parameters.Add("@choiceID", SqlDbType.Int); command3.Parameters.Add("@result", SqlDbType.Int).Direction = ParameterDirection.Output; parameter7.Value = Bill.OrderBillID; for (int i = 0; i < Bill.Items.Length; i++) { OrderBillItem item = Bill.Items[i]; command2.CommandText = "updateOrderBillDetail"; parameter6.Value = item.BillDetailID; parameter10.Value = item.Status; if (item.ServeTime.CompareTo(AppParameter.MinDateTime) <= 0) { parameter12.Value = DBNull.Value; } else { parameter12.Value = item.ServeTime; } if (item.CancelReasonID == 0) { parameter13.Value = DBNull.Value; } else { parameter13.Value = item.CancelReasonID; } parameter8.Value = item.MenuID; parameter9.Value = item.Unit; if (item.Message == null) { parameter11.Value = DBNull.Value; } else { parameter11.Value = item.Message; } parameter14.Value = item.EmployeeID; command2.ExecuteNonQuery(); item.BillDetailID = (int) parameter15.Value; if (item.BillDetailID == 0) { transaction.Rollback(); return "Can't update item"; } command3.CommandText = "deleteOrderBillOption"; if (command3.Parameters.Contains(parameter17)) { command3.Parameters.Remove(parameter17); } parameter16.Value = item.BillDetailID; command3.ExecuteNonQuery(); if (!item.DefaultOption && (item.ItemChoices != null)) { command3.Parameters.Add(parameter17); for (int j = 0; j < item.ItemChoices.Length; j++) { OrderItemChoice choice = item.ItemChoices[j]; command3.CommandText = "insertOrderBillOption"; parameter17.Value = choice.ChoiceID; command3.ExecuteNonQuery(); if (((int) parameter15.Value) == 0) { transaction.Rollback(); return "Can't insert choice"; } } } } } transaction.Commit(); transaction = null; } catch (Exception exception) { if (transaction != null) { transaction.Rollback(); } return exception.ToString(); } finally { if (connection != null) { connection.Close(); } } return null; }
public int PrintReceipt(int OrderBillID) { Printer.PrintReceipt.Print(OrderBillID); OrderBill bill = new OrderBill(); return bill.OrderBillPrint(OrderBillID); }