Exemplo n.º 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            Sale _sale = new Sale();

            if (String.IsNullOrEmpty(dateTimePicker1.Text))
            {
                MessageBox.Show("Select dateTimePicker");
                return;
            }

            try
            {
                customerCombo = customerComboBox.SelectedValue.ToString();

                if (Convert.ToInt32(customerCombo) <= 0)
                {
                    MessageBox.Show("Please,, Select any Customer..");
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Please,, Select any Customer..");
                return;
            }

            try
            {
                categoryCombo = categoryComboBox.SelectedValue.ToString();

                if (Convert.ToInt32(categoryCombo) <= 0)
                {
                    MessageBox.Show("Please,, Select any Category..");
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Please,, Select any Category..");
                return;
            }

            try
            {
                productCombo = productComboBox.SelectedValue.ToString();

                if (Convert.ToInt32(productCombo) <= 0)
                {
                    MessageBox.Show("Please,, Select any Product..");
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Please,, Select any Product..");
                return;
            }

            if (quantityTextBox.Text == "")
            {
                MessageBox.Show("Quantity field is requirde..");
                return;
            }

            if (mrpTextBox.Text == "")
            {
                MessageBox.Show("Mrp field is required");
                return;
            }

            if (totalMrpTextBox.Text == "")
            {
                MessageBox.Show("totalMrp field is required");
                return;
            }


            _salesBLL.AddButton(_sale);



            salesDataGridView.Visible  = true;
            submitDataGridView.Visible = false;
            MessageBox.Show("Added successfully");


            int row = 0;

            salesDataGridView.Rows.Add();
            row = salesDataGridView.Rows.Count - 2;
            salesDataGridView["CustomerCode", row].Value  = customerComboBox.Text;
            salesDataGridView["Date", row].Value          = dateTimePicker1.Text;
            salesDataGridView["LoyalityPoint", row].Value = loyalityPointTextBox.Text;
            salesDataGridView["Category", row].Value      = categoryComboBox.Text;
            salesDataGridView["Product", row].Value       = productComboBox.Text;
            salesDataGridView["Available", row].Value     = availableQuantityTextBox.Text;
            salesDataGridView["Qnty", row].Value          = quantityTextBox.Text;
            salesDataGridView["mrp", row].Value           = mrpTextBox.Text;
            salesDataGridView["TotalMrp", row].Value      = totalMrpTextBox.Text;

            total = total + Convert.ToDouble(totalMrpTextBox.Text);
            grandTotalTextBox.Text = total.ToString();

            double loyalityPoint = total / 1000;

            loyalityPointTextBox.Text = loyalityPoint.ToString();

            double discount = loyalityPoint / 10;

            discountTextBox.Text = discount.ToString();

            double discountAmount = total * discount / 100;

            discountAmountTextBox.Text = discountAmount.ToString();

            double payableAmount = total - discountAmount;

            payableAmountTextBox.Text = payableAmount.ToString();
        }