public void PayBill(Bill aBill)
        {
            try
            {
                //save record to database
                BillingDao.PayBill(aBill);

            }
            catch (HCSMSException ex)
            {
                raiseError(ex);
                throw new FaultException<HCSMSException>(ex);
            }
            catch (Exception ex)
            {
                raiseError(ex);
            }
        }
Пример #2
0
        public static void PayBill(Bill aBill)
        {
            List<SqlCommand> commands = new List<SqlCommand>();

            SqlCommand comm = new SqlCommand(@"insert into Bill(Id, TotalMoney, BillTime, Note, Type)
                                                                             values(@Id, @TotalAmount, @BillTime, @Note, @Type)");

            comm.Parameters.Add("@Id", SqlDbType.Char, 10);
            comm.Parameters.Add("@TotalMoney", SqlDbType.Decimal);
            comm.Parameters.Add("@BillTime", SqlDbType.DateTime);
            comm.Parameters.Add("@Note", SqlDbType.Text);
            comm.Parameters.Add("@Type", SqlDbType.Char, 10);

            comm.Parameters["@Id"].Value = aBill.Id;
            comm.Parameters["@TotalMoney"].Value = aBill.TotalMoney;
            comm.Parameters["@BillTime"].Value = aBill.BillTime;
            comm.Parameters["@Note"].Value = aBill.Note;
            comm.Parameters["@Type"].Value = aBill.Type;

            commands.Add(comm);
            foreach (BillingInfo info in aBill.BillingInfo)
            {
                comm = new SqlCommand(@"insert into BillUsingCard(BillingId, CardId, Money)
                                                                             values(@BillingId, @CardId, @Money))");

                comm.Parameters.Add("@BillingId", SqlDbType.Char, 10);
                comm.Parameters.Add("@CardId", SqlDbType.Char, 10);
                comm.Parameters.Add("@Money", SqlDbType.Decimal);

                comm.Parameters["@BillingId"].Value = aBill.Id;
                comm.Parameters["@CardId"].Value = info.Card.Id;
                comm.Parameters["@Money"].Value = info.Money;
                commands.Add(comm);
            }
            comm = new SqlCommand(@"Update DinningTable
                                                            set BillId=@BillngId
                                                         where Id=@DinningId");

            comm.Parameters.Add("@BillingId", SqlDbType.Char, 10);
            comm.Parameters.Add("@DinningId", SqlDbType.Char, 10);

            comm.Parameters["@BillingId"].Value = aBill.Id;
            comm.Parameters["@DinningId"].Value = aBill.BillingTable.Id;
            commands.Add(comm);

            foreach (BillingInfo info in aBill.BillingInfo)
            {
                comm = new SqlCommand(@"update MemberCard
                                                                                set CurrentMoney=CurrentMoney-@spent
                                                                                ,    MoneyCosumed=MoneyCosumed+@spent
                                                                             where Id=@cardId ");
                comm.CommandType = CommandType.StoredProcedure;

                comm.Parameters.Add("@spent", SqlDbType.Char, 10);
                comm.Parameters.Add("@cardId", SqlDbType.Char, 10);

                comm.Parameters["@spent"].Value = info.Money;
                comm.Parameters["@cardId"].Value = info.Card.Id;

                commands.Add(comm);
            }

            try
            {
                using (SqlConnection conn = Utilities.GetConnection())
                {
                    Utilities.TransactionExecuteNonQuery(conn, commands);
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number >= 50000)
                {
                    throw new HCSMSException(ex.Message);
                }
                else
                {
                    throw new HCSMSException("Transaction Errors !", ex);
                }
            }
        }
Пример #3
0
        private static Bill convertToBill(string Id, string dinningId, DateTime billTime,string note, decimal totalMoney, BillingInfo billInfo)
        {
            Bill bill = new Bill();

            bill.BillingInfo.Add(billInfo);
            bill.BillingTable.Id = dinningId;
            bill.BillTime = billTime;
            bill.Id = Id;
            bill.Note = note;
            bill.TotalMoney = totalMoney;

            return bill;
        }
Пример #4
0
 public void PayBill( Bill aBill, BillingInfo billingInfo)
 {
     throw new NotImplementedException();
 }