Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Money  moneyCostP, moneyMRP, moneySalesP = new Money();
            double costPrice, MRP, salesPrice;

            moneyCostP  = ControlValidation.IsValidPrice(txtCostPrice.Text.Trim());
            moneyMRP    = ControlValidation.IsValidPrice(txtMRP.Text.Trim());
            moneySalesP = ControlValidation.IsValidPrice(txtSalesPrice.Text.Trim());
            costPrice   = moneyCostP.Price;
            MRP         = moneyMRP.Price;
            salesPrice  = moneySalesP.Price;
            if (cmbCatagory.SelectedIndex <= 0)
            {
                lblError.Text      = "Please select valid catagory";
                lblError.ForeColor = Color.Red;
                cmbCatagory.Focus();
            }
            else if (cmbProductType.SelectedIndex <= 0)
            {
                lblError.Text      = "Please select valid Item Type";
                lblError.ForeColor = Color.Red;
                cmbProductType.Focus();
            }
            else if (cmbSubType.SelectedIndex <= 0)
            {
                lblError.Text      = "Please select valid Item sub-Type";
                lblError.ForeColor = Color.Red;
                cmbSubType.Focus();
            }
            else if (cmbVariety.SelectedIndex <= 0)
            {
                lblError.Text      = "Please select valid Item Variety";
                lblError.ForeColor = Color.Red;
                cmbVariety.Focus();
            }
            else if (cmbUnit.SelectedIndex <= 0)
            {
                lblError.Text      = "Please select valid Item Unit";
                lblError.ForeColor = Color.Red;
                cmbUnit.Focus();
            }
            else if (!moneyCostP.Result)
            {
                lblError.Text      = "Please Enter valid Dealer Price";
                lblError.ForeColor = Color.Red;
                txtCostPrice.Focus();
            }
            else if (!moneyMRP.Result)
            {
                lblError.Text      = "Please Enter valid MRP";
                lblError.ForeColor = Color.Red;
                txtMRP.Focus();
            }
            else if (!moneySalesP.Result)
            {
                lblError.Text      = "Please Enter valid Sales Price";
                lblError.ForeColor = Color.Red;
                txtSalesPrice.Focus();
            }
            else
            {
                //MessageBox.Show("Validation Done"+moneySalesP.Price.ToString());
                var result = AddPoductInfo(costPrice, MRP, salesPrice);
                if (result.Result)
                {
                    lblError.Text      = result.Message;
                    lblError.ForeColor = Color.Green;
                }
                else
                {
                    lblError.Text      = result.Message;
                    lblError.ForeColor = Color.Red;
                }
            }
        }