Пример #1
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            ClearControls ctr = new ClearControls();

            ctr.Clearcontrol(lbTotalPrice, txtPayment,
                             txtCustomerID, lbDiscount, lbReil, lbRemain, lbUs);
        }
Пример #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            double total = 0;

            try
            {
                if (txtPayment.Text == "")
                {
                    MessageBox.Show("Please, Input Payment !");
                    txtPayment.Focus();
                }
                else if (Convert.ToDouble(txtPayment.Text) < Convert.ToDouble(lbTotalPrice.Text.Remove(0, 1).ToString()))
                {
                    MessageBox.Show("Payment is not enough !. Please, Try again !");
                    txtPayment.Text = "";
                    txtPayment.Focus();
                }
                else if (rdbtnUs.Checked)
                {
                    total       = double.Parse(lbTotalPrice.Text.Remove(0, 1));
                    lbUs.Text   = "$" + (double.Parse(txtPayment.Text) - total).ToString("N2");
                    lbReil.Text = (double.Parse(lbUs.Text.Remove(0, 1)) * 4000).ToString("N2") + "​៛";
                    string p;
                    p             = lbReil.Text.Remove(lbReil.Text.LastIndexOf("​៛"), "​៛".Length);
                    lbRemain.Text = (double.Parse(p) % 4000).ToString("N2") + "​៛";
                }
                else if (rdbtnReils.Checked)
                {
                    total = double.Parse(lbTotalPrice.Text.Remove(0, 1));
                    double convertTotalToReil = total * 4000;
                    if (double.Parse(txtPayment.Text) < convertTotalToReil)
                    {
                        MessageBox.Show("Payment is not enough !. Please, Try again !");
                        ClearControls ctr = new ClearControls();
                        ctr.Clearcontrol(txtPayment, lbDiscount, lbReil, lbRemain, lbUs);
                        txtPayment.Focus();
                    }
                    else
                    {
                        lbUs.Text   = "$" + (double.Parse(txtPayment.Text) / 4000 - total).ToString("N2");
                        lbReil.Text = (double.Parse(lbUs.Text.Remove(0, 1)) * 4000).ToString("N2") + "​៛";
                        string p;
                        p             = lbReil.Text.Remove(lbReil.Text.LastIndexOf("​៛"), "​៛".Length);
                        lbRemain.Text = (double.Parse(p) % 4000).ToString("N2") + "​៛";
                    }
                }

                InsertDataToDatabase();
                CutStock();
            }
            catch
            {
            }
        }
Пример #3
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            ClearControls ctr = new ClearControls();

            ctr.Clearcontrol(txtUserName, txtUserPassword, cboStaffID);
            txtUserID.Text    = "Auto Number";
            txtUserID.Enabled = false;
            status            = "New";
            btnAdd.Text       = "Add";
            cboStaffID.Focus();
        }
Пример #4
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            ClearControls ctr = new ClearControls();

            ctr.Clearcontrol(txtDiscount, txtProductName, txtProductQty, txtSaleUnitPrice,
                             txtUnitPrice, cboCategory);
            txtProductID.Text = "Auto Number";
            txtProductName.Focus();
            status          = "New";
            btnSave.Enabled = true;
        }
Пример #5
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            ClearControls ctr = new ClearControls();

            txtCategoryID.Text    = "Auto Number";
            txtCategoryID.Enabled = false;
            ctr.Clearcontrol(txtCategoryName, txtDescription);
            txtCategoryName.Focus();
            status          = "New";
            btnSave.Text    = "Save";
            btnSave.Enabled = true;
        }
Пример #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Category cat = new Category();

            cat.CategoryID   = txtCategoryID.Text;
            cat.CategoryName = txtCategoryName.Text;
            cat.Description  = txtDescription.Text;
            if (txtCategoryName.Text == "")
            {
                txtCategoryName.Focus();
                MessageBox.Show("Please, Input Category Name !");
            }
            else if (txtDescription.Text == "")
            {
                txtDescription.Focus();
                MessageBox.Show("Please, Input Description !");
            }
            else
            {
                if (dgvCategory.SelectedRows.Count > 0)
                {
                    if (status == "New")
                    {
                        sql = "Insert Into tbCategory (CategoryName,Descriptions)Values('" + cat.CategoryName + "','" + cat.Description + "') ";
                        sms = "Category is Inserted !";
                    }
                    else if (status == "Old")
                    {
                        sql = "Update tbCategory Set CategoryName='" + cat.CategoryName + "',Descriptions='" + cat.Description + "'where CategoryID='" + cat.CategoryID + "'";
                        sms = "Category was Updated !";
                    }
                    try
                    {
                        SqlCommand cmd = new SqlCommand("dbo.spRunSQL", con);
                        cmd.Parameters.AddWithValue("@sql", sql);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();

                        MessageBox.Show(sms);
                        dgvCategory.DataSource = null;
                        FrmCategory_Load(sender, e);
                        ClearControls ctr = new ClearControls();
                        ctr.Clearcontrol(txtCategoryName, txtDescription);
                        txtCategoryID.Text = "Auto Number";
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Пример #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            User u = new User();

            u.id       = txtUserID.Text;
            u.username = txtUserName.Text;
            u.password = txtUserPassword.Text;
            u.StaffID  = int.Parse(cboStaffID.Text);
            try
            {
                if (status == "New")
                {
                    sql = "Insert Into tbUser(Username,Password,StaffID) values('" +
                          u.username + "','" + u.password + "','" + u.StaffID + "')";
                    sms = "Insert successfull !";
                }
                else if (status == "Old")
                {
                    sql = "Update tbUser set Username='******',Password='******',StaffID='" +
                          u.StaffID + "'Where UserID='" + u.id + "'";
                    sms         = "Update successfull !";
                    btnAdd.Text = "Add";
                }
                SqlCommand cmd = new SqlCommand(sql, connect.con);
                cmd.ExecuteNonQuery();
                MessageBox.Show(sms);
                FormUser_Load(sender, e);
                ClearControls ctr = new ClearControls();
                ctr.Clearcontrol(txtUserName, txtUserPassword, cboStaffID);
                txtUserID.Text    = "Auto Number";
                txtUserID.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }