Exemple #1
0
 // reset all the fields
 public void Reset()
 {
     GetProductId();
     productName.Clear();
     productType.Clear();
     buyingRate.Clear();
     saleRate.Clear();
     SKUTextbox.Clear();
     UnitCombox.SelectedIndex = -1;
     MinimumQuantity.Clear();
     vat.Clear();
     vatsale.Clear();
     logo.Image = null;
 }
Exemple #2
0
        //save button click
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (productId.Text != "" && productName.Text != "" && buyingRate.Text != "" && saleRate.Text != "")
            {
                if (String.IsNullOrEmpty(MinimumQuantity.Text))
                {
                    minQuantity = 0.0m;
                }
                else
                {
                    if (Double.TryParse(MinimumQuantity.Text.Trim(), out num))
                    {
                        minQuantity = Convert.ToDecimal(this.MinimumQuantity.Text.Trim());
                    }
                    else
                    {
                        MessageBox.Show("Enter Number Only");
                        MinimumQuantity.Clear();
                    }
                }
                if (String.IsNullOrEmpty(SKUTextbox.Text))
                {
                    barcode = null;
                }
                else
                {
                    barcode = SKUTextbox.Text;
                }

                if (Double.TryParse(buyingRate.Text.Trim(), out num) && Double.TryParse(saleRate.Text.Trim(), out num) && UnitCombox.Text != "" && Double.TryParse(vat.Text.Trim(), out num))
                {
                    try
                    {
                        // update the product using  aupdate model
                        aUpdateProductModel.ProductName        = productName.Text;
                        aUpdateProductModel.ProductType        = productType.Text;
                        aUpdateProductModel.ProductBuyingRate  = Convert.ToDecimal(buyingRate.Text);
                        aUpdateProductModel.ProductSellingRate = Convert.ToDecimal(saleRate.Text);
                        aUpdateProductModel.Vat = Convert.ToDecimal(vat.Text);
                        aUpdateProductModel.ProductSaleRateWithVat = Convert.ToDecimal(vatsale.Text);
                        aUpdateProductModel.Barcode                = barcode;
                        aUpdateProductModel.ProductUnit            = UnitCombox.Text;
                        aUpdateProductModel.ProductMinimumQuantity = minQuantity;


                        ProductManager newProductManager = new ProductManager();
                        int            isDone            = newProductManager.ProductUpdate(aUpdateProductModel);
                        if (isDone > 0)
                        {
                            MessageBox.Show("Update Sucessfully");
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Update Unsucessful");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Try Again");
                    }
                }
                else
                {
                    MessageBox.Show("Please Enter Number Only");
                    buyingRate.Clear();
                    saleRate.Clear();
                    MinimumQuantity.Clear();
                }
            }


            else
            {
                MessageBox.Show("Please Fill The Data");
            }
        }
Exemple #3
0
        //  save button
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (productId.Text != "" && productName.Text != "" && buyingRate.Text != "" && saleRate.Text != "")
            {
                if (String.IsNullOrEmpty(MinimumQuantity.Text))
                {
                    minQuantity = 0.0m;
                }
                else
                {
                    if (Double.TryParse(MinimumQuantity.Text.Trim(), out num))
                    {
                        minQuantity = Convert.ToDecimal(this.MinimumQuantity.Text.Trim());
                    }
                    else
                    {
                        MessageBox.Show("Enter Number Only");
                        MinimumQuantity.Clear();
                    }
                }
                if (String.IsNullOrEmpty(SKUTextbox.Text))
                {
                    barcode = null;
                }
                else
                {
                    barcode = SKUTextbox.Text;
                }

                if (Double.TryParse(buyingRate.Text.Trim(), out num) && Double.TryParse(saleRate.Text.Trim(), out num) && UnitCombox.Text != "" && Double.TryParse(vat.Text.Trim(), out num))
                {
                    try
                    {
                        //creating  ProductModel class and Save All data to object
                        ProductModel aProductModel = new ProductModel();
                        aProductModel.ProductName        = productName.Text;
                        aProductModel.ProductType        = productType.Text;
                        aProductModel.ProductBuyingRate  = Convert.ToDecimal(buyingRate.Text);
                        aProductModel.ProductSellingRate = Convert.ToDecimal(saleRate.Text);
                        aProductModel.Vat = Convert.ToDecimal(vat.Text);
                        aProductModel.ProductSaleRateWithVat = Convert.ToDecimal(vatsale.Text);
                        aProductModel.Barcode                = barcode;
                        aProductModel.ProductUnit            = UnitCombox.Text;
                        aProductModel.ProductMinimumQuantity = minQuantity;
                        aProductModel.ProductImage           = image;
                        // calling manager to insert data

                        int isDone = newProductManager.ProductInsert(aProductModel);
                        if (isDone > 0)
                        {
                            MessageBox.Show("Inserted Sucessfully");
                            Reset();
                        }
                        else
                        {
                            MessageBox.Show("Insert Unsucessful");
                            Reset();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Try Again");
                        Reset();
                    }
                }
                else
                {
                    MessageBox.Show("Please Enter Number Only");
                    buyingRate.Clear();
                    saleRate.Clear();
                    MinimumQuantity.Clear();
                }
            }


            else
            {
                MessageBox.Show("Please Fill The Data");
            }
        }