Esempio n. 1
0
        public BILLS GetBILLS(int Id)
        {
            BILLS  bills            = null;
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM BILLS WHERE Id = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", Id);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            bills = new BILLS();

                            if (dr["Id"] != DBNull.Value)
                            {
                                bills.Id = (int)dr["Id"];
                            }

                            if (dr["Billing_Date"] != DBNull.Value)
                            {
                                bills.Billing_Date = (DateTime)dr["Billing_Date"];
                            }

                            if (dr["Payment_Date"] != DBNull.Value)
                            {
                                bills.Payment_Date = (DateTime)dr["Payment_Date"];
                            }

                            if (dr["Amount"] != DBNull.Value)
                            {
                                bills.Amount = (double)dr["Amount"];
                            }

                            if (dr["Created_At"] != DBNull.Value)
                            {
                                bills.Created_At = (DateTime)dr["Created_At"];
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(bills);
        }
        public int createNewBills(int orderNumber)
        {
            ORDERS_DISHES_DB odm = new ORDERS_DISHES_DB(Configuration);
            ORDERS_DB        om  = new ORDERS_DB(Configuration);

            SERVICE_CLASS_DB scm = new SERVICE_CLASS_DB(Configuration);
            DELIVERY_DB      dm  = new DELIVERY_DB(Configuration);

            ORDERS orders = om.GetORDERS(orderNumber);

            BILLS bills = new BILLS();

            bills.Amount = odm.GetAmount(orders) + scm.GetAmount(dm.GetDELIVERY(orders.Fk_Id_Delivery));
            bills        = BILLS_DB.AddBILLS(bills);
            return(bills.Id);
        }
Esempio n. 3
0
        public ORDERS confirmOrders(int orderNumber)
        {
            ORDERS orders = ORDERS_DB.GetORDERS(orderNumber);

            orders.Fk_Id_Order_Status = 4;

            BILLS_DB bm    = new BILLS_DB(Configuration);
            BILLS    bills = bm.GetBILLS(orders.Fk_Id_Bills);

            bm.UpdateBILLS_Payment_Date(bills);

            DELIVERY_DB dm       = new DELIVERY_DB(Configuration);
            DELIVERY    delivery = dm.GetDELIVERY(orders.Fk_Id_Delivery);

            delivery.Fk_Id_Delivery_Status = 4;
            dm.UpdateDELIVERY_Fk_Id_Delivery_Status(delivery);

            return(ORDERS_DB.UpdateORDERS_Fk_Id_Order_Status(orders));
        }
Esempio n. 4
0
        public BILLS AddBILLS(BILLS bills)
        {
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "INSERT INTO BILLS (Billing_Date, Amount, Created_At) VALUES (GETDATE(), @Amount, GETDATE()); SELECT SCOPE_IDENTITY()";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@Amount", bills.Amount);
                    cn.Open();

                    bills.Id = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(bills);
        }
Esempio n. 5
0
        public BILLS UpdateBILLS_Payment_Date(BILLS bills)
        {
            string connectionString = Config.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "UPDATE BILLS SET Payment_Date=GETDATE() WHERE Id=@Id;";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@Id", bills.Id);

                    cn.Open();

                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(bills);
        }