private void STOCK_Load(object sender, EventArgs e)
        {
            ListBox lb = new ListBox();

            lb.Items.Add(productidGV);

            lb.Items.Add(productnameGV);

            lb.Items.Add(productbarcodeGV);

            lb.Items.Add(productbuyingpriceGV);

            lb.Items.Add(BuyingDateGV);

            lb.Items.Add(expirydateGV);

            lb.Items.Add(productcategoryGV);

            lb.Items.Add(availablestockGV);

            lb.Items.Add(statusGV);

            SQL_TASKS.load_data("st_getSTOCK", stocks_dataGridView, lb);

            //foreach(DataGridViewRow row in stocks_dataGridView.Rows)
            //{
            //    if(Convert.ToInt32(row.Cells["availablestockGV"].Value) == 0)
            //    {
            //        stocks_dataGridView.Columns["availablestockGV"].DefaultCellStyle.BackColor = Color.Red;

            //        //row.Cells["availablestockGV"].Style.BackColor = Color.Red;
            //        //row.DefaultCellStyle.BackColor = Color.Red;
            //    }
            //}
        }
Esempio n. 2
0
        private void Purchase_Invoice_Details_Load(object sender, EventArgs e)
        {
            Hashtable ht = new Hashtable();

            ht.Add("@month", dateTimePicker_invoicedetails.Value.Month);

            ht.Add("@year", dateTimePicker_invoicedetails.Value.Year);

            SQL_TASKS.LoadListModifiedHashTable("st_getPURCHASEINVOICELIST", purchaseinvoice_comboBox, "ID", "Company", ht);

            purchaseinvoice_dataGridView.AutoGenerateColumns = false;

            //LoadPurchaseInvoiceDetails();

            //purchaseinvoice_comboBox.SelectedIndex = -1;

            base.add_button.Visible = false;

            base.view_button.Visible = false;

            base.edit_button.Visible = false;

            base.delete_button.Visible = false;

            base.search_groupBox.Visible = false;

            base.save_button.Visible = false;

            base.cancel_button.Visible = false;
        }
Esempio n. 3
0
        public override void search_textBox_TextChanged(object sender, EventArgs e)
        {
            if (search_textBox.Text != "")
            {
                ListBox lb = new ListBox();

                lb.Items.Add(supplierIDGV);

                lb.Items.Add(suppliernameGV);

                lb.Items.Add(contactpersonnameGV);

                lb.Items.Add(phone1GV);

                lb.Items.Add(phone2GV);

                lb.Items.Add(addressGV);

                lb.Items.Add(ntnGV);

                lb.Items.Add(statusGV);

                Hashtable ht = new Hashtable();

                ht.Add("@data", search_textBox.Text);

                SQL_TASKS.load_data("st_searchSUPPLIERS", suppliers_dataGridView, lb, ht);
            }
            else
            {
                loadSuppliers();
            }
        }
        public void LoadStocks()
        {
            ListBox lb = new ListBox();

            lb.Items.Add(productidGV);

            lb.Items.Add(productnameGV);

            lb.Items.Add(productbarcodeGV);

            //lb.Items.Add(PerUnitPriceGV);

            lb.Items.Add(productbuyingpriceGV);

            lb.Items.Add(BuyingDateGV);

            lb.Items.Add(expirydateGV);

            lb.Items.Add(productcategoryGV);

            lb.Items.Add(availablestockGV);

            lb.Items.Add(statusGV);

            SQL_TASKS.load_data("st_getSTOCK", stocks_dataGridView, lb);
        }
        public override void search_textBox_TextChanged(object sender, EventArgs e)
        {
            if (search_textBox.Text != "")
            {
                ListBox lb = new ListBox();

                lb.Items.Add(productidGV);

                lb.Items.Add(productnameGV);

                lb.Items.Add(productbarcodeGV);

                lb.Items.Add(expirydateGV);

                lb.Items.Add(categoryIDGV);

                lb.Items.Add(productcategoryGV);

                Hashtable ht = new Hashtable();

                ht.Add("@data", search_textBox.Text);

                SQL_TASKS.load_data("st_searchPRODUCTS", products_dataGridView, lb, ht);
            }
            else
            {
                LoadProducts();
            }
        }
        private void PURCHASE_INVOICE_Load(object sender, EventArgs e)
        {
            enable_crude_buttons(); MainClass.disbale_reset(left_panel_sample2);

            SQL_TASKS.LoadList("st_loadlistSUPPLIERS", supplier_comboBox, "ID", "Supplier Company");

            total_amount_label.Text = "0.00";

            gross_total_price_label.Text = "0.00";
        }
Esempio n. 7
0
        private void dateTimePicker_invoicedetails_ValueChanged(object sender, EventArgs e)
        {
            Hashtable ht = new Hashtable();

            ht.Add("@month", dateTimePicker_invoicedetails.Value.Month);

            ht.Add("@year", dateTimePicker_invoicedetails.Value.Year);

            SQL_TASKS.LoadListModifiedHashTable("st_getPURCHASEINVOICELIST", purchaseinvoice_comboBox, "ID", "Company", ht);
        }
        private void Products_Load(object sender, EventArgs e)
        {
            reset_disable();

            LoadProducts();

            SQL_TASKS.LoadList("st_getcategorieslist", categories_comboBox, "ID", "Category");

            enable_crude_buttons();
        }
Esempio n. 9
0
        public void LoadCategory()
        {
            ListBox lb = new ListBox();

            lb.Items.Add(categoryidGV);

            lb.Items.Add(categorynameGV);

            lb.Items.Add(categorystatusGV);

            SQL_TASKS.load_data("st_getcategoriesdata", categories_dataGridView, lb);
        }
        public override void add_button_Click(object sender, EventArgs e)
        {
            SQL_TASKS.LoadList("st_getcategorieslist", categories_comboBox, "ID", "Category");

            reset_enable();

            edit = 0;

            view_button.Enabled = false;

            delete_button.Enabled = false;
        }
Esempio n. 11
0
        private void PRODUCT_PRICING_Load(object sender, EventArgs e)
        {
            SQL_TASKS.LoadList("st_getcategorieslist", category_comboBox_product_pricing, "ID", "Category");

            enable_crude_buttons();

            product_pricing_dataGridView.AutoGenerateColumns = false;

            foreach (DataGridViewRow row in product_pricing_dataGridView.Rows)
            {
                product_pricing_dataGridView.Rows.Remove(row);
            }
        }
        private void SALES_REPORT_Load(object sender, EventArgs e)
        {
            if (Sales_Invoice_Details.SaleID == 0)
            {
                SQL_TASKS.ShowReport(crystalReportViewer1, "st_getSalesReceipt", "@userID", LoginCodeClass.USERID);
            }
            else
            {
                SQL_TASKS.ShowReport(crystalReportViewer1, "st_getSalesReceiptwrtSalesID", "@saleID", Sales_Invoice_Details.SaleID);

                Sales_Invoice_Details.SaleID = 0;
            }
        }
Esempio n. 13
0
        private void refresh_button_Click(object sender, EventArgs e)
        {
            Hashtable ht = new Hashtable();

            ht.Add("@month", dateTimePicker_invoicedetails.Value.Month);

            ht.Add("@year", dateTimePicker_invoicedetails.Value.Year);

            SQL_TASKS.LoadListModifiedHashTable("st_getPURCHASEINVOICELIST", purchaseinvoice_comboBox, "ID", "Company", ht);

            purchaseinvoice_dataGridView.AutoGenerateColumns = false;

            LoadPurchaseInvoiceDetails(); gross_total_price_label.Text = "0.00";
        }
        void LoadProducts()
        {
            ListBox lb = new ListBox();

            lb.Items.Add(productidGV);

            lb.Items.Add(productnameGV);

            lb.Items.Add(productbarcodeGV);

            lb.Items.Add(expirydateGV);

            lb.Items.Add(categoryIDGV);

            lb.Items.Add(productcategoryGV);

            SQL_TASKS.load_data("st_getPRODUCTS", products_dataGridView, lb);
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (search_stock_textBox.Text != "")
            {
                ListBox lb = new ListBox();

                lb.Items.Add(productnameGV);

                Hashtable ht = new Hashtable();

                ht.Add("@data", search_stock_textBox.Text);

                SQL_TASKS.load_data("st_searchSTOCKS", stocks_dataGridView, lb, ht);
            }
            else
            {
                LoadStocks();
            }
        }
        public void loadUsers()
        {
            ListBox lb = new ListBox();

            lb.Items.Add(useridGV);

            lb.Items.Add(nameGV);

            lb.Items.Add(emailGV);

            lb.Items.Add(passwordGV);

            lb.Items.Add(phonenumberGV);

            lb.Items.Add(statusGV);

            lb.Items.Add(roleGV);

            SQL_TASKS.load_data("st_getusersdata", users_dataGridView, lb);
        }
        private void search_textBox_TextChanged_1(object sender, EventArgs e)
        {
            if (search_textBox.Text != "")
            {
                ListBox lb = new ListBox();

                lb.Items.Add(useridGV);

                lb.Items.Add(nameGV);

                lb.Items.Add(emailGV);

                lb.Items.Add(passwordGV);

                lb.Items.Add(phonenumberGV);

                lb.Items.Add(statusGV);

                lb.Items.Add(roleGV);

                Hashtable ht = new Hashtable();

                ht.Add("@data", search_textBox.Text);

                SQL_TASKS.load_data("st_searchUSERS", users_dataGridView, lb, ht);

                if (users_dataGridView.Rows.Count == 0)
                {
                    not_found_label.Visible = true;
                }
                else
                {
                    not_found_label.Visible = false;
                }
            }
            else
            {
                loadUsers();
            }
        }
        void LoadSales()
        {
            var ht = new Hashtable();

            ht.Add("@saleID", Convert.ToInt64(sale_ID_textBox.Text));

            var lb = new ListBox();

            lb.Items.Add(saleIDGV);

            lb.Items.Add(BarcodeGV);

            lb.Items.Add(ProductGV);

            lb.Items.Add(QuantityGV);

            lb.Items.Add(TotalDiscountGV);

            lb.Items.Add(TotalAmountGV);

            lb.Items.Add(AmountGivenGV);

            lb.Items.Add(AmountReturnedGV);

            lb.Items.Add(DateGV);

            lb.Items.Add(ProductPriceGV);

            lb.Items.Add(PerProductDiscountGV);

            lb.Items.Add(PerProductTotalGV);

            lb.Items.Add(UserIDGV);

            lb.Items.Add(PaymentGV);

            lb.Items.Add(ProductIDGV);

            SQL_TASKS.load_data("st_getSalesReceiptwrtSalesID", sales_return_dataGridView, lb, ht);
        }
Esempio n. 19
0
        public void loadSuppliers()
        {
            ListBox lb = new ListBox();

            lb.Items.Add(supplierIDGV);

            lb.Items.Add(suppliernameGV);

            lb.Items.Add(contactpersonnameGV);

            lb.Items.Add(phone1GV);

            lb.Items.Add(phone2GV);

            lb.Items.Add(addressGV);

            lb.Items.Add(ntnGV);

            lb.Items.Add(statusGV);

            SQL_TASKS.load_data("st_getSUPPLIERS", suppliers_dataGridView, lb);
        }
Esempio n. 20
0
        void LoadProducts()
        {
            Hashtable ht = new Hashtable();

            ht.Add("@categID", Convert.ToInt32(category_comboBox_product_pricing.SelectedValue));

            ListBox lb = new ListBox();

            lb.Items.Add(productIDGV);

            lb.Items.Add(productnameGV);

            lb.Items.Add(buyingpriceGV);

            lb.Items.Add(PerUnitPriceGV);

            lb.Items.Add(QuantityGV);

            lb.Items.Add(BarcodeGV);

            SQL_TASKS.load_data("getPRODUCTSwrtCATEGORIES", product_pricing_dataGridView, lb, ht);
        }
Esempio n. 21
0
        private void LoadPurchaseInvoiceDetails()
        {
            Hashtable ht = new Hashtable();

            ht.Add("@purchaseinvoiceID", Convert.ToInt64(purchaseinvoice_comboBox.SelectedValue));

            ListBox lb = new ListBox();

            lb.Items.Add(purchaseinvoiceIDGV);

            lb.Items.Add(productIDGV);

            lb.Items.Add(productnameGV);

            lb.Items.Add(productquantityGV);

            lb.Items.Add(perunitpriceGV);

            lb.Items.Add(totalGV);

            SQL_TASKS.load_data("st_getPURCHASEINVOICEDETAILS", purchaseinvoice_dataGridView, lb, ht);
        }
Esempio n. 22
0
        public override void search_textBox_TextChanged(object sender, EventArgs e)
        {
            if (search_textBox.Text != "")
            {
                ListBox lb = new ListBox();

                lb.Items.Add(categoryidGV);

                lb.Items.Add(categorynameGV);

                lb.Items.Add(categorystatusGV);

                Hashtable ht = new Hashtable();

                ht.Add("@data", search_textBox.Text);

                SQL_TASKS.load_data("st_searchCATEGORIES", categories_dataGridView, lb, ht);
            }
            else
            {
                LoadCategory();
            }
        }
Esempio n. 23
0
        void LoadSalesDetails()
        {
            var ht = new Hashtable();

            ht.Add("@date", dateTimePicker_sales.Value);

            var lb = new ListBox();

            lb.Items.Add(saleIDGV);

            lb.Items.Add(TotalAmountGV);

            lb.Items.Add(AmountGivenGV);

            lb.Items.Add(AmountReturnedGV);

            lb.Items.Add(UserGV);

            lb.Items.Add(TotalDiscountGV);

            lb.Items.Add(UserIDGV);

            SQL_TASKS.load_data("st_GetDailySales", sales_details_dataGridView, lb, ht);
        }
Esempio n. 24
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            if (category_name_textBox.Text == "" || is_active_category_comboBox.SelectedIndex == -1)
            {
                MainClass.ShowMsg("Please enter a record to delete.", "error");

                reset_disable();

                enable_crude_buttons();
            }
            else if (category_name_textBox.Enabled == true || is_active_category_comboBox.Enabled == true)
            {
                MainClass.ShowMsg("Please select record from the table.", "error");

                reset_disable();

                enable_crude_buttons();
            }
            else if ((category_name_textBox.Enabled == false && is_active_category_comboBox.Enabled == false) && (category_name_textBox.Text != "" && is_active_category_comboBox.SelectedIndex != -1))
            {
                try
                {
                    DialogResult ans = MessageBox.Show("Are you sure you want to delete current record.", "CONFIRM?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (ans == DialogResult.Yes)
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@id", categoryID);

                        if (SQL_TASKS.insert_update_delete("st_deletecategories", ht) > 0)
                        {
                            MainClass.ShowMsg(category_name_textBox.Text + " deleted successfully.", "Success");

                            reset_disable();

                            enable_crude_buttons();

                            LoadCategory();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            reset_disable();

                            enable_crude_buttons();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                    reset_disable();

                    sql_con.Close();

                    enable_crude_buttons();
                }
            }
        }
Esempio n. 25
0
        public override void save_button_Click(object sender, EventArgs e)
        {
            if (category_name_textBox.Text == "" || is_active_category_comboBox.SelectedIndex == -1)
            {
                MainClass.ShowMsg("Please enter all required information.", "error");

                reset_disable();

                enable_crude_buttons();
            }
            else
            {
                if (Convert.ToString(is_active_category_comboBox.SelectedItem) == "Yes")
                {
                    stat = 1; //active
                }
                else if (Convert.ToString(is_active_category_comboBox.SelectedItem) == "No")
                {
                    stat = 0; //in-active
                }

                if (edit == 0) //0 to add record
                {
                    try
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@name", category_name_textBox.Text);

                        ht.Add("@isActive", stat);

                        if (SQL_TASKS.insert_update_delete("st_insertcategories", ht) > 0)
                        {
                            MainClass.ShowMsg(category_name_textBox.Text + " added successfully to the system.", "Success");

                            reset_disable();

                            enable_crude_buttons();

                            LoadCategory();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            reset_disable();

                            enable_crude_buttons();
                        }

                        LoadCategory();

                        enable_crude_buttons();

                        reset_disable();
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMsg(ex.Message, "error");

                        reset_disable();

                        enable_crude_buttons();
                    }
                }
                else if (edit == 1) // to update record
                {
                    if (Convert.ToString(is_active_category_comboBox.SelectedItem) == "Yes")
                    {
                        stat = 1; //active
                    }
                    else if (Convert.ToString(is_active_category_comboBox.SelectedItem) == "No")
                    {
                        stat = 0; //in-active
                    }

                    try
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@id", categoryID);

                        ht.Add("@name", category_name_textBox.Text);

                        ht.Add("@isActive", stat);

                        if (SQL_TASKS.insert_update_delete("st_updatecategories", ht) > 0)
                        {
                            MainClass.ShowMsg(category_name_textBox.Text + " updated successfully to the system.", "Success");

                            reset_disable();

                            enable_crude_buttons();

                            LoadCategory();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            reset_disable();

                            enable_crude_buttons();
                        }

                        LoadCategory();

                        edit = 0;
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMsg(ex.Message, "error");

                        reset_disable();

                        enable_crude_buttons();
                    }
                }
            }
        }
Esempio n. 26
0
        public override void save_button_Click(object sender, EventArgs e)
        {
            if (supplier_name_textBox.Text == "" || contact_person_textBox.Text == "" || phone1_textBox.Text == "" || address_textBox_suppliers.Text == "" || NTN_textBox.Text == "" || supplier_status_comboBox.SelectedIndex == -1)
            {
                MainClass.ShowMsg("Please enter all required information.", "error");

                MainClass.disbale_reset(left_panel_sample2);

                enable_crude_buttons();
            }
            else
            {
                if (Convert.ToString(supplier_status_comboBox.SelectedItem) == "Active")
                {
                    stat = 1; //active
                }
                else if (Convert.ToString(supplier_status_comboBox.SelectedItem) == "In-active")
                {
                    stat = 0; //in-active
                }

                if (edit == false) //0 to add record
                {
                    try
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@suppliername", supplier_name_textBox.Text);

                        ht.Add("@contactpersonname", contact_person_textBox.Text);

                        ht.Add("@phone1", phone1_textBox.Text);

                        ht.Add("@phone2", phone2_textBox.Text);

                        ht.Add("@address", address_textBox_suppliers.Text);

                        ht.Add("@ntn", NTN_textBox.Text);

                        ht.Add("@status", stat);

                        if (SQL_TASKS.insert_update_delete("st_insertSUPPLIERS", ht) > 0)
                        {
                            MainClass.ShowMsg(supplier_name_textBox.Text + " added successfully to the system.", "Success");

                            MainClass.disbale_reset(left_panel_sample2);

                            enable_crude_buttons();

                            loadSuppliers();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            MainClass.disbale_reset(left_panel_sample2);

                            enable_crude_buttons();
                        }
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMsg(ex.Message, "Error");

                        MainClass.disbale_reset(left_panel_sample2);

                        enable_crude_buttons();
                    }
                }
                else if (edit == true) // to update record
                {
                    if (Convert.ToString(supplier_status_comboBox.SelectedItem) == "Active")
                    {
                        stat = 1; //active
                    }
                    else if (Convert.ToString(supplier_status_comboBox.SelectedItem) == "In-active")
                    {
                        stat = 0; //in-active
                    }

                    try
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@suppliername", supplier_name_textBox.Text);

                        ht.Add("@contactpersonname", contact_person_textBox.Text);

                        ht.Add("@phone1", phone1_textBox.Text);

                        ht.Add("@phone2", phone2_textBox.Text);

                        ht.Add("@address", address_textBox_suppliers.Text);

                        ht.Add("@ntn", NTN_textBox.Text);

                        ht.Add("@status", stat);

                        ht.Add("@supp_id", supplierID);

                        if (SQL_TASKS.insert_update_delete("st_updateSUPPLIERS", ht) > 0)
                        {
                            MainClass.ShowMsg(supplier_name_textBox.Text + " updated successfully.", "Success");

                            MainClass.disbale_reset(left_panel_sample2);

                            enable_crude_buttons();

                            loadSuppliers();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            MainClass.disbale_reset(left_panel_sample2);

                            enable_crude_buttons();
                        }
                        edit = false;

                        loadSuppliers();
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMsg(ex.Message, "error");

                        MainClass.disbale_reset(left_panel_sample2);

                        enable_crude_buttons();
                    }
                }
            }
        }
Esempio n. 27
0
        public override void delete_button_Click(object sender, EventArgs e)
        {
            if (supplier_name_textBox.Text == "" || contact_person_textBox.Text == "" || phone1_textBox.Text == "" || address_textBox_suppliers.Text == "" || NTN_textBox.Text == "" || supplier_status_comboBox.SelectedIndex == -1)
            {
                MainClass.ShowMsg("Please enter a record to delete.", "error");

                MainClass.disbale_reset(left_panel_sample2);

                enable_crude_buttons();
            }
            else if (supplier_name_textBox.Enabled == true || contact_person_textBox.Enabled == true || phone1_textBox.Enabled == true || address_textBox_suppliers.Enabled == true || NTN_textBox.Enabled == true || supplier_status_comboBox.Enabled == true)
            {
                MainClass.ShowMsg("Please select record from the table.", "error");

                MainClass.disbale_reset(left_panel_sample2);

                enable_crude_buttons();
            }
            else if ((supplier_name_textBox.Enabled == false || contact_person_textBox.Enabled == false || phone1_textBox.Enabled == false || address_textBox_suppliers.Enabled == false || NTN_textBox.Enabled == false || supplier_status_comboBox.Enabled == false) && (supplier_name_textBox.Text != "" || contact_person_textBox.Text != "" || phone1_textBox.Text != "" || address_textBox_suppliers.Text != "" || NTN_textBox.Text != "" || supplier_status_comboBox.SelectedIndex != -1))
            {
                try
                {
                    DialogResult ans = MessageBox.Show("Are you sure you want to delete current record.", "CONFIRM?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (ans == DialogResult.Yes)
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@supp_id", supplierID);

                        if (SQL_TASKS.insert_update_delete("st_deleteSUPPLIERS", ht) > 0)
                        {
                            MainClass.ShowMsg(supplier_name_textBox.Text + " deleted successfully.", "Success");

                            MainClass.disbale_reset(left_panel_sample2);

                            enable_crude_buttons();

                            loadSuppliers();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            MainClass.disbale_reset(left_panel_sample2);

                            enable_crude_buttons();
                        }

                        MainClass.disbale_reset(left_panel_sample2);

                        enable_crude_buttons();

                        loadSuppliers();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                    MainClass.disbale_reset(left_panel_sample2);

                    enable_crude_buttons();
                }
            }
        }
Esempio n. 28
0
        private void purchaseinvoice_dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (LoginCodeClass.isAdmin != true)
                {
                    if (e.RowIndex != -1 && e.ColumnIndex != -1)
                    {
                        if (e.ColumnIndex == 6)
                        {
                            DataGridViewRow row = purchaseinvoice_dataGridView.Rows[e.RowIndex];

                            DialogResult dr = MessageBox.Show("Are you sure you want to delete?\n\nIt will affect your stock.", "PRODUCT DELETION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (dr == DialogResult.Yes)
                            {
                                using (TransactionScope sc = new TransactionScope())
                                {
                                    Hashtable ht = new Hashtable();

                                    ht.Add("@purchID", Convert.ToInt64(purchaseinvoice_comboBox.SelectedValue.ToString()));

                                    ht.Add("@userID", LoginCodeClass.USERID);

                                    ht.Add("@proID", Convert.ToInt32(row.Cells["productIDGV"].Value));

                                    ht.Add("@quan", Convert.ToInt32(row.Cells["productquantityGV"].Value));

                                    ht.Add("@date", DateTime.Today);

                                    SQL_TASKS.insert_update_delete("st_insertDeletedItemPI", ht);

                                    int q; object ob;

                                    ob = SQL_TASKS.getProductQuantity(Convert.ToInt32(row.Cells["productIDGV"].Value.ToString()));

                                    bool update = true;

                                    if (ob != null || Convert.ToInt32(ob) != 0)
                                    {
                                        update = true;
                                    }
                                    else
                                    {
                                        update = false;
                                    }

                                    if (update)
                                    {
                                        //update

                                        q = Convert.ToInt32(ob);

                                        q -= Convert.ToInt32(row.Cells["productquantityGV"].Value.ToString());

                                        Hashtable ht1 = new Hashtable();

                                        ht1.Add("@prodID", Convert.ToInt32(row.Cells["productIDGV"].Value.ToString()));

                                        ht1.Add("@quan", q);

                                        SQL_TASKS.insert_update_delete("st_updateSTOCK", ht1);

                                        Hashtable ht3 = new Hashtable();

                                        ht3.Add("@purchaseinvoicedetailsID", Convert.ToInt64(row.Cells["purchaseinvoiceIDGV"].Value.ToString()));

                                        if (SQL_TASKS.insert_update_delete("st_deletePRODUCTSfromPURCHASEINVOICEDETAILS", ht3) > 0)
                                        {
                                            MainClass.ShowMsg("Deleted successfully.", "Success");

                                            gross_total_price_label.Text = "0.00";

                                            LoadPurchaseInvoiceDetails(); purchaseinvoice_comboBox.SelectedIndex = -1;
                                        }
                                        else
                                        {
                                            MainClass.ShowMsg("Unable to delete.", "Error");

                                            gross_total_price_label.Text = "0.00";

                                            purchaseinvoice_comboBox.SelectedIndex = -1;
                                        }

                                        sc.Complete();
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception("Admin cannot delete purchase invoice details.To delete purchase invoice details login with an user account.");
                }
            }
            catch (Exception ex)
            {
                MainClass.ShowMsg(ex.Message, "Error");
            }
        }
 private void SalesReturnReceipt_Load(object sender, EventArgs e)
 {
     SQL_TASKS.ShowReportSaleReturn(SalesReturncrystalReportViewer, "st_getRefundInvoice", "@saleID", "1");
 }
        public override void save_button_Click(object sender, EventArgs e)
        {
            if (product_name_textBox.Text == "" || barcode_textBox.Text == "" || dateTimePicker_expiry_products.Value < DateTime.Today || categories_comboBox.SelectedIndex == -1)
            {
                MainClass.ShowMsg("Please enter all required information.", "Error");

                reset_disable();

                enable_crude_buttons();
            }
            else
            {
                if (edit == 0) //0 to add record
                {
                    try
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@productname", product_name_textBox.Text);

                        ht.Add("@productbarcode", barcode_textBox.Text);

                        ht.Add("@productexpirydate", dateTimePicker_expiry_products.Value);

                        ht.Add("@productcategoryID", Convert.ToInt32(categories_comboBox.SelectedValue.ToString()));

                        if (SQL_TASKS.insert_update_delete("st_insertPRODUCTS", ht) > 0)
                        {
                            MainClass.ShowMsg(product_name_textBox.Text + " added successfully to the system.", "Success");

                            reset_disable();

                            enable_crude_buttons();

                            LoadProducts();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            reset_disable();

                            enable_crude_buttons();
                        }

                        LoadProducts();

                        enable_crude_buttons();

                        reset_disable();
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMsg(ex.Message, "Error");

                        reset_disable();

                        enable_crude_buttons();
                    }
                }
                else if (edit == 1) // to update record
                {
                    try
                    {
                        Hashtable ht = new Hashtable();

                        ht.Add("@productid", productID);

                        ht.Add("@productname", product_name_textBox.Text);

                        ht.Add("@productbarcode", barcode_textBox.Text);

                        ht.Add("@productexpirydate", dateTimePicker_expiry_products.Value);

                        ht.Add("@productcategoryID", Convert.ToInt32(categories_comboBox.SelectedValue.ToString()));

                        if (SQL_TASKS.insert_update_delete("st_updatePRODUCTS", ht) > 0)
                        {
                            MainClass.ShowMsg(product_name_textBox.Text + " updated successfully to the system.", "Success");

                            reset_disable();

                            enable_crude_buttons();

                            LoadProducts();
                        }
                        else
                        {
                            MainClass.ShowMsg("Unable to save record.", "Error");

                            reset_disable();

                            enable_crude_buttons();
                        }

                        edit = 0;
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMsg(ex.Message, "Error");

                        reset_disable();

                        enable_crude_buttons();
                    }
                }
            }
        }