public ReportOnSales()
 {
     InitializeComponent();
     reportOnSaleDataGridView.DataSource = _stockManager.Display();
 }
Пример #2
0
        private void SaveButton(object sender, EventArgs e)
        {
            //Input field
            //Set Price as Mandatory
            _product.ID = Convert.ToInt32(categoryComboBox.SelectedValue);
            if (String.IsNullOrEmpty(categoryComboBox.Text))
            {
                MessageBox.Show("Must be Select Can not be Empty!!!");
                return;
            }

            _product.Code = codeTextBox.Text;
            //Set Code as Mandatory
            if (String.IsNullOrEmpty(_product.Code))
            {
                MessageBox.Show("Code Can not be Empty!!!");
                return;
            }
            //Code Lenth 4
            if (_product.Code.Length != 4)
            {
                MessageBox.Show("Please 4 disig requeired");
                return;
            }
            //Check UNIQUE
            if (_stockManager.IsCodeExists(_product))
            {
                MessageBox.Show(codeTextBox.Text + "Code already Exist !");
                return;
            }

            _product.Name = nameTextBox.Text;
            //Set Price as Mandatory
            if (String.IsNullOrEmpty(_product.Name))
            {
                MessageBox.Show("Name Can not be Empty!!!");
                return;
            }
            //Check UNIQUE
            if (_stockManager.IsNameExists(_product))
            {
                MessageBox.Show(nameTextBox.Text + "Name already Exist !");
                return;
            }
            //Set Price as Mandatory
            if (String.IsNullOrEmpty(reOrderTextBox.Text))
            {
                MessageBox.Show("ReOrder Leve Can not be Empty!!!");
                return;
            }
            _product.ReorderLevel = Convert.ToInt32(reOrderTextBox.Text);

            _product.ProductDescription = descriptionTextBox.Text;
            //call Method and show gridview
            //showDataGridView.DataSource = _stockManager.GetSave(_product);
            showDataGridView.DataSource = _stockManager.Display();


            //Update information Afsar
            if (saveButton.Text == "Save")
            {
                if (_stockManager.GetSave(_product))
                {
                    MessageBox.Show("Data Saved Successfully..!!");
                    showDataGridView.DataSource = _stockManager.GetProductDisplay();
                }
                else
                {
                    MessageBox.Show("Not Saved..!!");
                }
            }
            else
            {
                if (_stockManager.Update(_product))
                {
                    MessageBox.Show("Data Update Successfully..!!");
                    showDataGridView.DataSource = _stockManager.GetProductDisplay();
                }
                else
                {
                    MessageBox.Show("Not Update..!!");
                }
            }

            //clear field
            nameTextBox.Clear();
            codeTextBox.Clear();
            reOrderTextBox.Clear();
            descriptionTextBox.Clear();
        }
Пример #3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            //Code



            if (String.IsNullOrEmpty(codeTextBox.Text))
            {
                MessageBox.Show("Code Can not be Empty!!!");
                return;
            }

            if (codeTextBox.TextLength != 4)
            {
                MessageBox.Show("Code Must be 4 Charecter");
            }
            _supplier.Code = codeTextBox.Text;

            if (_stockManager.IsCodeExists(_supplier))
            {
                MessageBox.Show(codeTextBox.Text + " Already Exists!");
                return;
            }



            //Name



            if (String.IsNullOrEmpty(nameTextBox.Text))
            {
                MessageBox.Show("Name Can not be Empty!!!");
                return;
            }

            _supplier.Name = nameTextBox.Text;
            //Address

            _supplier.Address = addressTextBox.Text;

            //Email



            if (String.IsNullOrEmpty(emailTextBox.Text))
            {
                MessageBox.Show("Email Can not be Empty!!!");
                return;
            }

            _supplier.Email = emailTextBox.Text;

            if (_stockManager.IsEmailExists(_supplier))
            {
                MessageBox.Show(emailTextBox.Text + "Already Exists!");
                return;
            }

            //Contact



            if (String.IsNullOrEmpty(contactTextBox.Text))
            {
                MessageBox.Show("contact Can not be Empty!!!");
                return;
            }

            _supplier.Contact = contactTextBox.Text;

            if (_stockManager.IsContactExists(_supplier))
            {
                MessageBox.Show(contactTextBox.Text + "Already Exists!");
                return;
            }

            //Contact Person

            _supplier.ContactPerson = contactPersonTextBox.Text;

            //bool isAdded = _stockManager.Save(_supplier);

            //if (isAdded)
            //{
            //    MessageBox.Show("Saved");
            //}
            //else
            //{
            //    MessageBox.Show("Not Saved");
            //}

            showDataGridView.DataSource = _stockManager.Display();

            if (saveButton.Text == "Save")
            {
                if (_stockManager.Save(_supplier))
                {
                    MessageBox.Show("Saved!");
                    showDataGridView.DataSource = _stockManager.Display();
                }
                else
                {
                    MessageBox.Show("Not saved!");
                }
            }

            else
            {
                if (_stockManager.Update(_supplier))
                {
                    saveButton.Text = "Save";
                    MessageBox.Show("Updated!");
                    showDataGridView.DataSource = _stockManager.Display();
                }
                else
                {
                    MessageBox.Show("Not Updated!");
                }
            }

            codeTextBox.Clear();
            nameTextBox.Clear();
            addressTextBox.Clear();
            emailTextBox.Clear();
            contactTextBox.Clear();
            contactPersonTextBox.Clear();
            showDataGridView.DataSource = _stockManager.Display();
        }
 public Stock()
 {
     InitializeComponent();
     stockDataGridView.DataSource = _stockManager.Display();
 }