Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(quantity.ToString() + " " + unit_of_measurement);

            classes.Inventory_Stocks stocks = new classes.Inventory_Stocks();
            stocks.quantity            = quantity;
            stocks.unit_of_measurement = unit_of_measurement;

            if (stocks.create_stocks())
            {
                if (hasCapacity == true)
                {
                    classes.Inventory_Capacity cp = new classes.Inventory_Capacity();
                    cp.capacity      = capacity;
                    cp.capacity_size = capacity_size;
                    cp.create_capacity();
                }

                classes.Inventory_ProductInformation pi = new classes.Inventory_ProductInformation();
                pi.inventory_type = inventory_type;
                pi.item_name      = item_name;
                pi.description    = description;
                pi.brand          = brand;
                pi.model          = model;
                pi.serial_number  = serial_number;
                pi.hasCapacity    = hasCapacity;
                pi.expire_at      = date_expired;

                if (pi.create_product_information())
                {
                    classes.Inventory inv = new classes.Inventory();
                    inv.category_id     = category_id;
                    inv.category_name   = category_name;
                    inv.supplier_id     = supplier_id;
                    inv.supplier_name   = supplier_name;
                    inv.property_number = property_number;
                    inv.department_id   = department_id;
                    inv.department_name = department_name;
                    inv.status          = status;
                    inv.date_acquired   = date_acquired;

                    if (inv.create_inventory())
                    {
                        MessageBox.Show(item_name + " has been added", "Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        admin.inv.ucInventory.instance.display_inventory_data();
                        ((Form)this.TopLevelControl).Close();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
        private void update_product_information()
        {
            if (string.IsNullOrEmpty(txtItemName.Text))
            {
                MessageBox.Show("Please indicate the item name.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtItemName.Text = "";
                txtItemName.Focus();
            }
            else
            {
                if (string.IsNullOrEmpty(txtDescription.Text))
                {
                    MessageBox.Show("Please indicate the description of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtDescription.Text = "";
                    txtDescription.Focus();
                }
                else
                {
                    if (string.IsNullOrEmpty(txtBrand.Text))
                    {
                        MessageBox.Show("Please indicate the brand of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtBrand.Text = "";
                        txtBrand.Focus();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(txtModel.Text))
                        {
                            MessageBox.Show("Please indicate the model of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtModel.Text = "";
                            txtModel.Focus();
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(txtSerialNumber.Text))
                            {
                                MessageBox.Show("Please indicate the serial number of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtSerialNumber.Text = "";
                                txtSerialNumber.Focus();
                            }
                            else
                            {
                                if (chkCapacity.Checked)
                                {
                                    if (string.IsNullOrEmpty(cbCapacity.Text))
                                    {
                                        MessageBox.Show("Please indicate the capacity of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        txtSerialNumber.Text = "";
                                        txtSerialNumber.Focus();
                                    }
                                    else
                                    {
                                        if (cbCapacity.Text == "--Select--" || cbCapacity.SelectedIndex == 0 || cbCapacity.SelectedIndex == -1)
                                        {
                                            MessageBox.Show("Please indicate the capacity size of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            cbCapacity.SelectedIndex = 0;
                                            cbCapacity.Focus();
                                        }
                                    }
                                }

                                if (string.IsNullOrEmpty(txtPropertyNumber.Text))
                                {
                                    MessageBox.Show("Please indicate the propery number of the item.", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    txtPropertyNumber.Text = "";
                                    txtPropertyNumber.Focus();
                                }
                                else
                                {
                                    inv_prod_info = new classes.Inventory_ProductInformation();

                                    inv_prod_info.inventory_id   = inventory_id;
                                    inv_prod_info.inventory_type = inventory_type;

                                    inv_prod_info.item_name     = txtItemName.Text;
                                    inv_prod_info.description   = txtDescription.Text;
                                    inv_prod_info.brand         = txtBrand.Text;
                                    inv_prod_info.model         = txtModel.Text;
                                    inv_prod_info.serial_number = txtSerialNumber.Text;

                                    inv_prod_info.hasCapacity   = (chkCapacity.Checked) ? true : false;
                                    inv_prod_info.capacity_id   = capacity_id;
                                    inv_prod_info.capacity      = Convert.ToInt32(txtCapacity.Text);
                                    inv_prod_info.capacity_size = capacity_size;

                                    inv_prod_info.property_number = txtPropertyNumber.Text;

                                    foreach (Control control in panel1.Controls)
                                    {
                                        if (control.GetType() == typeof(Guna.UI2.WinForms.Guna2RadioButton))
                                        {
                                            Guna.UI2.WinForms.Guna2RadioButton rdb = control as Guna.UI2.WinForms.Guna2RadioButton;
                                            if (rdb.Checked)
                                            {
                                                inv_prod_info.status = rdb.Text;
                                            }
                                        }
                                    }

                                    inv_prod_info.acquired_at = dtpDateAcquired.Value;
                                    inv_prod_info.expire_at   = dtpDateExpiry.Value;

                                    if (inv_prod_info.update_product_information())
                                    {
                                        MessageBox.Show("Item has been updated!", "Update Product Information", MessageBoxButtons.OK, MessageBoxIcon.Question);
                                        frmViewItem.instance.display_selected_inventory(inventory_id);
                                        this.Close();
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }