public override void saveButton_Click(object sender, EventArgs e)
        {
            if (displayDataGridView.Rows.Count > 0)
            {
                Int64     purchaseInvoiceID;
                insertion i = new insertion();
                updation  u = new updation();
                using (TransactionScope sc = new TransactionScope())
                {
                    purchaseInvoiceID = i.insertPurchaseInvoice(DateTime.Today, retrival.USER_ID,
                                                                Convert.ToInt32(supplierComboBox.SelectedValue));

                    foreach (DataGridViewRow row in displayDataGridView.Rows)
                    {
                        co += i.insertPurchaseInvoiceDetails(purchaseInvoiceID, Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()), Convert.ToSingle(row.Cells["totalGV"].Value.ToString()));
                        if (r.checkProductPriceExistance(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString())))
                        {
                            u.updateProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString()));
                        }
                        else
                        {
                            i.insertProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString()));
                        }

                        int    q;
                        object ob = r.getProductQuantity(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()));
                        if (ob != null)
                        {
                            q  = Convert.ToInt32(ob);
                            q += Convert.ToInt32(row.Cells["quantGV"].Value.ToString());
                            u.updateStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), q);
                        }
                        else
                        {
                            i.insertStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()));
                        }
                    }
                    if (co > 0)
                    {
                        MainClass.ShowMsg("Purchase Invoice Created Successfully.", "Success", "Success");
                    }
                    else
                    {
                        MainClass.ShowMsg("Unable to create purchase invoice.", "Error", "Error");
                    }
                    sc.Complete();
                }
            }
        }
Esempio n. 2
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (productTextBox.Text == "")
            {
                productNameErrorLabel.Visible = true;
            }
            else
            {
                productNameErrorLabel.Visible = false;
            }
            if (barcodeTextBox.Text == "")
            {
                barcodeErrorLabel.Visible = true;
            }
            else
            {
                barcodeErrorLabel.Visible = false;
            }
            if (expiryDateTimePicker.Value < DateTime.Now)
            {
                expiryDateLabel.Visible = true; expiryDateLabel.Text = "invalid Date";
            }
            else
            {
                expiryDateLabel.Visible = false;
            }
            if (expiryDateTimePicker.Value.Date == DateTime.Now.Date)
            {
                expiryDateLabel.Visible = false;
            }

            if (categoryComboBox.SelectedIndex == -1 || categoryComboBox.SelectedIndex == 0)
            {
                categoryErrorLabel.Visible = true;
            }
            else
            {
                categoryErrorLabel.Visible = false;
            }


            if (productNameErrorLabel.Visible || barcodeErrorLabel.Visible || expiryDateLabel.Visible || categoryErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();
                    if (expiryDateTimePicker.Value.Date == DateTime.Now.Date)
                    {
                        i.insertProduct(productTextBox.Text, barcodeTextBox.Text,
                                        Convert.ToInt32(categoryComboBox.SelectedValue));
                    }
                    else
                    {
                        i.insertProduct(productTextBox.Text, barcodeTextBox.Text,
                                        Convert.ToInt32(categoryComboBox.SelectedValue), expiryDateTimePicker.Value);
                    }


                    r.showProducts(displayDataGridView, proIDGV, proGV, ExpiryGV, catGV, barcodeGV, CatIDGV);
                    MainClass.disableReset(leftPanel);
                }
                else if (edit == 1) //Code for UPDATE operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to update record?", "Question..",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (expiryDateTimePicker.Value.Date == DateTime.Now.Date)
                        {
                            u.updateProduct(prodId, productTextBox.Text, barcodeTextBox.Text, Convert.ToInt32(categoryComboBox.SelectedValue));
                        }
                        else
                        {
                            u.updateProduct(prodId, productTextBox.Text, barcodeTextBox.Text, Convert.ToInt32(categoryComboBox.SelectedValue), expiryDateTimePicker.Value);
                        }

                        r.showProducts(displayDataGridView, proIDGV, proGV, ExpiryGV, catGV, barcodeGV, CatIDGV);
                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (supplierTextBox.Text == "")
            {
                supplierNameErrorLabel.Visible = true;
            }
            else
            {
                supplierNameErrorLabel.Visible = false;
            }
            if (personNameTextBox.Text == "")
            {
                contactPersonLabel.Visible = true;
            }
            else
            {
                contactPersonLabel.Visible = false;
            }
            if (phone1TextBox.Text == "")
            {
                phoneErrorLabel.Visible = true;
            }
            else
            {
                phoneErrorLabel.Visible = false;
            }
            if (addressTextBox.Text == "")
            {
                addressErrorLabel.Visible = true;
            }
            else
            {
                addressErrorLabel.Visible = false;
            }
            if (statusComboBox.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (supplierNameErrorLabel.Visible || contactPersonLabel.Visible || phoneErrorLabel.Visible ||
                addressErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (statusComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();

                    if (phone2TextBox.Text == "" && nTNTextBox.Text != "")
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, nTNTextBox.Text);
                    }
                    else if (phone2TextBox.Text != "" && nTNTextBox.Text == "")
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, null);
                    }
                    else if (phone2TextBox.Text == "" && nTNTextBox.Text == "")
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, null);
                    }
                    else
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, nTNTextBox.Text);
                    }
                    r.showSuppliers(displayDataGridView, suppIDGV, comGV, conPerGV, phone1GV, phone2GV, addressGV,
                                    ntnGV, statusGV);
                    MainClass.disableReset(leftPanel);
                }
                else if (edit == 1) //Code for UPDATE operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to update record?", "Question..",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (statusComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        if (phone2TextBox.Text == "" && nTNTextBox.Text != "")
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, nTNTextBox.Text);
                        }
                        else if (phone2TextBox.Text != "" && nTNTextBox.Text == "")
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, null);
                        }
                        else if (phone2TextBox.Text == "" && nTNTextBox.Text == "")
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, null);
                        }
                        else
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, nTNTextBox.Text);
                        }

                        r.showSuppliers(displayDataGridView, suppIDGV, comGV, conPerGV, phone1GV, phone2GV, addressGV,
                                        ntnGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
Esempio n. 4
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text == "")
            {
                nameErrorLabel.Visible = true;
            }
            else
            {
                nameErrorLabel.Visible = false;
            }
            if (usernameTextBox.Text == "")
            {
                usernameErrorLabel.Visible = true;
            }
            else
            {
                usernameErrorLabel.Visible = false;
            }
            if (passwordTextBox.Text == "")
            {
                passwordErrorLabel.Visible = true;
            }
            else
            {
                passwordErrorLabel.Visible = false;
            }
            if (emailTextBox.Text == "")
            {
                emailErrorLabel.Visible = true;
            }
            else
            {
                emailErrorLabel.Visible = false;
            }
            if (phoneTextBox.Text == "")
            {
                phoneErrorLabel.Visible = true;
            }
            else
            {
                phoneErrorLabel.Visible = false;
            }
            if (statusComboBox.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (nameErrorLabel.Visible || usernameErrorLabel.Visible || passwordErrorLabel.Visible ||
                emailErrorLabel.Visible || phoneErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (statusComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();


                    i.insertUser(nameTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, emailTextBox.Text, phoneTextBox.Text, stat);
                    r.showUsers(displayDataGridView, userIDGV, NameGV, UserNameGV, passGV, EmailGV, PhoneGV, statusGV);
                    MainClass.disableReset(leftPanel);
                }
                else if (edit == 1) //Code for UPDATE operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to update record?", "Question..",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (statusComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateUser(userId, nameTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, emailTextBox.Text, phoneTextBox.Text, stat);
                        r.showUsers(displayDataGridView, userIDGV, NameGV, UserNameGV, passGV, EmailGV, PhoneGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
Esempio n. 5
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (categoryTextBox.Text == "")
            {
                categoryNameErrorLabel.Visible = true;
            }
            else
            {
                categoryNameErrorLabel.Visible = false;
            }


            if (isActiveComboBox.SelectedIndex == -1)
            {
                isActiveErrorLabel.Visible = true;
            }
            else
            {
                isActiveErrorLabel.Visible = false;
            }

            if (isActiveErrorLabel.Visible || categoryNameErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (isActiveComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (isActiveComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();


                    i.insertCat(categoryTextBox.Text, stat);
                    r.showCategories(displayDataGridView, catIDGV, NameGV, statusGV);
                    MainClass.disableReset(leftPanel);
                }
                else if (edit == 1) //Code for UPDATE operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to update record?", "Question..",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (isActiveComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (isActiveComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catId, categoryTextBox.Text, stat);
                        r.showCategories(displayDataGridView, catIDGV, NameGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }