Пример #1
0
        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
        private void getOrderId()
        {
            var orders_dt = conn.Select("orders", "MAX(order_id)").GetQueryData();

            if (orders_dt.Rows.Count == 0)
            {
                //Should not preemptively insert into the database
                //conn.Insert("orders", "order_id", "1").GetQueryData();
                order_no.Text = "1";
            }
            else
            {
                int order_id = orders_dt.Rows[0][0] + 1;
                order_no.Text = order_id.ToString();
            }
        }
Пример #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            username = txtUsername.Text;
            string password = txtPassword.Text;
            var    users_dt = conn.Select("users", "*")
                              .Where("username", username, "password", password)
                              .GetQueryData();

            if (users_dt.Rows.Count == 1)
            {
                userid            = users_dt.Rows[0][0].ToString();
                fn                = users_dt.Rows[0][3].ToString();
                ln                = users_dt.Rows[0][4].ToString();
                this.DialogResult = DialogResult.OK;
                Close();
            }
        }