Exemple #1
0
        private string sumExtension()
        {
            ValidationBill validate     = new ValidationBill();
            string         sumextension = "";

            if (validate.Requiredcbo(txtpos) == false)
            {
                sumextension += "\n Pos wrong";
            }
            if (validate.Required(txtinmoney) == false)
            {
                sumextension += "\n Pay money not null";
            }
            if (validate.Required(txtinmoney) == true)
            {
                if (validate.Compared(float.Parse(txtamount.Text), float.Parse(txtinmoney.Text)) == false)
                {
                    sumextension = "\n Pay money not lower than total money";
                }
            }
            if (validate.Requiredcbo(cboaccount) == false)
            {
                sumextension += "\n User not null";
            }
            if (validate.RangeDatagridview(lstbilldetail) == false)
            {
                sumextension += "\n Bill must have product";
            }
            return(sumextension);
        }
Exemple #2
0
        private void lstbilldetail_DoubleClick(object sender, EventArgs e)
        {
            bool delete = db.Authorities.Single(x => x.AccountID == getAccount && x.NameOfAuthority == "Manage Invoice").Delete;

            if (delete == true)
            {
                ValidationBill vali = new ValidationBill();
                if (lstbilldetail.SelectedRows.Count == 1 && lstbilldetail.SelectedRows[0].Cells["ProductID"].Value != null)
                {
                    DialogResult rs = MessageBox.Show("Do you want to delete this?", "Delete Row", MessageBoxButtons.YesNo);
                    if (rs == DialogResult.Yes)
                    {
                        lstbilldetail.Rows.Remove(this.lstbilldetail.SelectedRows[0]);
                    }
                    int   soluong = 0;
                    float amount  = 0;
                    try
                    {
                        for (int i = 0; i < lstbilldetail.RowCount; i++)
                        {
                            soluong += (int)lstbilldetail.Rows[i].Cells["Quantity"].Value;
                            amount  += (float)lstbilldetail.Rows[i].Cells["Total"].Value;
                        }
                    }
                    catch
                    {
                    }
                    txtsl.Text         = soluong.ToString();
                    txtamount.Text     = amount.ToString();
                    numsoluong.Visible = false;
                    try
                    {
                        float outp = float.Parse(txtinmoney.Text) - float.Parse(txtamount.Text);
                        if (outp < 0)
                        {
                            txtoutmoney.Text = "0";
                        }
                        else
                        {
                            txtoutmoney.Text = outp.ToString();
                        }
                    }
                    catch
                    {
                        txtoutmoney.Text = "0";
                    }
                }
            }
            else
            {
                MessageBox.Show("Your account do not have the authority to delete Invoice!");
            }
        }
Exemple #3
0
        private void txtinmoney_TextChanged(object sender, EventArgs e)
        {
            ValidationBill validate = new ValidationBill();

            if (validate.CheckNumTextbox(txtinmoney) == true)
            {
                if (validate.RangeDatagridview(lstbilldetail) == true)
                {
                    try
                    {
                        float outp = float.Parse(txtinmoney.Text) - float.Parse(txtamount.Text);
                        if (outp < 0)
                        {
                            txtoutmoney.Text = "0";
                        }
                        else
                        {
                            txtoutmoney.Text = outp.ToString();
                        }
                    }
                    catch
                    {
                        txtoutmoney.Text = "0";
                    }
                }
                else
                {
                    txtoutmoney.Text = txtinmoney.Text;
                }
            }
            else
            {
                if (txtinmoney.Text == "" && txtamount.Text == "0")
                {
                }
                else
                {
                    MessageBox.Show("Must input number in this field");
                }
            }
        }