コード例 #1
0
ファイル: Main.cs プロジェクト: CS-SourceCode/cs-merch-system
        public void payOrder(string oID, decimal payment)
        {
            var test = new DatabaseConn();
            // toDo: 1 insert for payment
            var present_pay = test.Select("order_payment", "SUM(payment)")
                              .NJoin("orders")
                              .Where("order_id", oID)
                              .Group("order_id")
                              .GetQueryData()
                              .Rows[0][0];
            decimal total_pay = Convert.ToDecimal(present_pay) + payment;

            MessageBox.Show(total_pay.ToString());
            test.Insert("order_payment", "order_id", oID, "payment", payment.ToString(), "payment_date",
                        DateTime.Now.ToString("yyyy-MM-dd"))
            .GetQueryData();
            var total_price = test.Select("orderline", "SUM(total_price)")
                              .Where("order_id", oID)
                              .Group("order_id")
                              .GetQueryData()
                              .Rows[0][0];

            if (total_pay >= total_price)
            {
                test.Update("orders", "payment_status", "1")
                .Where("order_id", oID)
                .GetQueryData();
            }
            showOrderDetails();
        }
コード例 #2
0
        private void customer_save_Click(object sender, EventArgs e)
        {
            int parse;

            if (customer_fname.Text == "" || customer_lname.Text == "" || customer_cluster.Text == "" || (customer_contact.Text == "" || !int.TryParse(customer_contact.Text, out parse)))
            {
                MessageBox.Show("Please make sure all fields are filled in correctly.");
            }
            else
            {
                string firstname = customer_fname.Text;
                string lastname  = customer_lname.Text;

                var tempcust_dt = conn.Select("customer", "*")
                                  .Where("firstname", firstname, "lastname", lastname)
                                  .GetQueryData();

                if (tempcust_dt.Rows.Count == 1)
                {
                    MessageBox.Show("Customer already exists!");
                }
                else
                {
                    conn.Insert("customer", "firstname", customer_fname.Text, "lastname", customer_lname.Text, "contact", customer_contact.Text, "cluster", customer_cluster.Text).GetQueryData();
                }
                mainMenu.setCustomerlist();
            }
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: CS-SourceCode/cs-merch-system
        public void claimOrder(string olID, decimal quantity)
        {
            if (quantity == 0)
            {
                return;
            }
            var itemDetails = conn.Select("orderline", "quantity", "quantity_claimed")
                              .Where("orderline_id", olID)
                              .GetQueryData();
            decimal quantityClaimed = Convert.ToDecimal(itemDetails.Rows[0][1].ToString());
            decimal total           = Convert.ToDecimal(itemDetails.Rows[0][0].ToString());
            decimal max             = total - quantityClaimed;

            //checks if claimed quantity is more than possible, if true will set quantity to max possible
            quantity         = quantity > max ? max : quantity;
            quantityClaimed += quantity;
            conn.Update("orderline", "quantity_claimed", quantityClaimed.ToString())
            .Where("orderline_id", olID)
            .GetQueryData();
            conn.Insert("order_claim", "orderline_id", olID, "quantity_no", quantity.ToString(), "date_claimed",
                        DateTime.Now.ToString("yyyy-MM-dd"))
            .GetQueryData();
            showOrderDetails();
        }