Esempio n. 1
0
        private void metroLink2_Click(object sender, EventArgs e)
        {
            try
            {
                int          pid      = 0;
                M_Product_BS IndexObj = new M_Product_BS();
                foreach (DataGridViewRow item in this.tblProduct.SelectedRows)
                {
                    pid = Convert.ToInt32(item.Cells[0].Value.ToString());
                }


                bool result = cObjList.Any();
                if (result)
                {
                    if (tblProduct.RowCount > 0)
                    {
                        foreach (M_Product_BS item in cObjList)
                        {
                            if (item.ID == pid)
                            {
                                IndexObj = item;
                            }
                        }

                        if (IndexObj.Delete(con))
                        {
                            MetroMessageBox.Show(this, "Product data Successfully deleted", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            loadGrid();
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "Product was not deleted", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        txtEPid.Enabled      = false;
                        txtEPname.Enabled    = false;
                        txtEPrice.Enabled    = false;
                        txtECost.Enabled     = false;
                        cmbECategory.Enabled = false;
                        //txtEBoundlePrice.Enabled = false;
                        lnkSearch.Enabled      = false;
                        numericUpDown1.Enabled = false;
                        //txtPackagecost.Enabled = false;
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "Table data is empty ", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MetroMessageBox.Show(this, "Table list is empty ", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void InitialloadGrid()
        {
            try
            {
                List <GetProductStock>          GridList = new List <GetProductStock>();
                BusinessObjects.GetProductStock spObj    = new GetProductStock();
                GridList = spObj.getProdAlongWithStockQuantity_All(con);

                List <M_Product_BS>          cObjList = new List <M_Product_BS>();
                BusinessObjects.M_Product_BS cObj     = new M_Product_BS();
                cObjList = cObj.GetProducts(con);
                //MessageBox.Show(cObjList.Count.ToString());

                //this is to set the category name

                List <Category_BS> catList = new List <Category_BS>();
                Category_BS        catObj  = new Category_BS();
                catList = catObj.GetCategory(con);
                foreach (Category_BS itemCat in catList)
                {
                    foreach (GetProductStock itemProd in GridList)
                    {
                        if (itemProd.category == itemCat.ID)
                        {
                            itemProd.catObj = itemCat;
                        }
                    }
                }

                int i = 0;
                tblProduct.Rows.Clear();


                foreach (GetProductStock item in GridList)
                {
                    if (item.TotalQuantity > 3)
                    {
                        continue;
                    }
                    tblProduct.Rows.Add();
                    tblProduct.Rows[i].Cells[0].Value = item.ID;
                    tblProduct.Rows[i].Cells[1].Value = item.name;
                    tblProduct.Rows[i].Cells[2].Value = item.catObj.name;
                    tblProduct.Rows[i].Cells[3].Value = item.cost;
                    tblProduct.Rows[i].Cells[4].Value = item.unitPrice;

                    tblProduct.Rows[i].Cells[5].Value = item.warranty;
                    tblProduct.Rows[i].Cells[6].Value = item.TotalQuantity;



                    i++;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        private void autoComplete()
        {
            try
            {
                txtInvoiceSearch.AutoCompleteMode   = AutoCompleteMode.Suggest;
                txtInvoiceSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
                txtSNameSearch.AutoCompleteMode     = AutoCompleteMode.Suggest;
                txtSNameSearch.AutoCompleteSource   = AutoCompleteSource.CustomSource;
                txtPNameSearch.AutoCompleteMode     = AutoCompleteMode.Suggest;
                txtPNameSearch.AutoCompleteSource   = AutoCompleteSource.CustomSource;

                txtSupName.AutoCompleteMode   = AutoCompleteMode.Suggest;
                txtSupName.AutoCompleteSource = AutoCompleteSource.CustomSource;

                AutoCompleteStringCollection stringColl  = new AutoCompleteStringCollection();
                AutoCompleteStringCollection stringColl2 = new AutoCompleteStringCollection();
                AutoCompleteStringCollection stringColl3 = new AutoCompleteStringCollection();

                M_Product_BS product = new M_Product_BS();
                ProductList = product.GetProducts(con);

                foreach (BusinessObjects.M_Product_BS item in ProductList)
                {
                    stringColl.Add(item.name);
                }

                //retreive stock data
                Stock sc = new Stock();

                StockList = sc.GetStockList(con);


                foreach (BusinessObjects.Stock item in StockList)
                {
                    stringColl2.Add(item.sup_name);
                    stringColl3.Add(item.invoice_no.ToString());
                }
                txtPNameSearch.AutoCompleteCustomSource   = stringColl;
                txtSNameSearch.AutoCompleteCustomSource   = stringColl2;
                txtInvoiceSearch.AutoCompleteCustomSource = stringColl3;

                txtSupName.AutoCompleteCustomSource = stringColl2;

                BusinessObjects.Category_BS catObj = new BusinessObjects.Category_BS();
                CategoryList = catObj.GetCategory(con);

                cmbECategory.DataSource = null;
                cmbECategory.DataSource = CategoryList;

                cmbECategory.DisplayMember = "name";
                cmbECategory.ValueMember   = "ID";
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        private void loadGrid(List <GetProductStock> List_)
        {
            try
            {
                GridList = List_;

                BusinessObjects.M_Product_BS cObj = new M_Product_BS();
                cObjList = cObj.GetProducts(con);


                //this is to set the category name
                foreach (Category_BS itemCat in catList)
                {
                    foreach (GetProductStock itemProd in GridList)
                    {
                        if (itemProd.category == itemCat.ID)
                        {
                            itemProd.catObj = itemCat;
                        }
                    }
                }

                int i = 0;
                tblProduct.Rows.Clear();


                foreach (GetProductStock item in GridList)
                {
                    tblProduct.Rows.Add();
                    tblProduct.Rows[i].Cells[0].Value = item.ID;
                    tblProduct.Rows[i].Cells[1].Value = item.name;
                    tblProduct.Rows[i].Cells[2].Value = item.catObj.name;
                    tblProduct.Rows[i].Cells[3].Value = item.cost;
                    tblProduct.Rows[i].Cells[4].Value = item.unitPrice;

                    tblProduct.Rows[i].Cells[5].Value = item.warranty;
                    tblProduct.Rows[i].Cells[6].Value = item.TotalQuantity;
                    tblProduct.Rows[i].Cells[7].Value = item.date_;



                    i++;
                }
                // autoComplete();
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
 private void InitialloadGrid()
 {
     try
     {
         BusinessObjects.GetProductStock spObj = new GetProductStock();
         BusinessObjects.M_Product_BS    cObj  = new M_Product_BS();
         cObjList = cObj.GetProducts(con);
         Category_BS catObj = new Category_BS();
         catList = catObj.GetCategory(con);
     }
     catch (Exception ex)
     {
         MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 6
0
        private void loadGrid()
        {
            try
            {
                BusinessObjects.M_Product_BS cObj = new M_Product_BS();
                cObjList = cObj.GetProducts(con);
                //MessageBox.Show(cObjList.Count.ToString());
                Category_BS catObj = new Category_BS();
                catList = catObj.GetCategory(con);
                foreach (Category_BS itemCat in catList)
                {
                    foreach (M_Product_BS itemProd in cObjList)
                    {
                        if (itemProd.category == itemCat.ID)
                        {
                            itemProd.catObj = itemCat;
                        }
                    }
                }

                int i = 0;
                tblProduct.Rows.Clear();

                //MessageBox.Show(cObjList.Count.ToString());
                foreach (M_Product_BS item in cObjList)
                {
                    tblProduct.Rows.Add();
                    tblProduct.Rows[i].Cells[0].Value = item.ID;
                    tblProduct.Rows[i].Cells[1].Value = item.name;
                    tblProduct.Rows[i].Cells[2].Value = item.catObj.name;
                    tblProduct.Rows[i].Cells[3].Value = item.cost;
                    tblProduct.Rows[i].Cells[4].Value = item.unitPrice;

                    tblProduct.Rows[i].Cells[5].Value = item.warranty;
                    tblProduct.Rows[i].Cells[6].Value = "Edit";



                    i++;
                }
                autoComplete();
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 7
0
        void autoComplete()
        {
            try
            {
                txtReceiptNo.AutoCompleteMode     = AutoCompleteMode.Suggest;
                txtReceiptNo.AutoCompleteSource   = AutoCompleteSource.CustomSource;
                txtProductName.AutoCompleteMode   = AutoCompleteMode.Suggest;
                txtProductName.AutoCompleteSource = AutoCompleteSource.CustomSource;

                AutoCompleteStringCollection stringColl  = new AutoCompleteStringCollection();
                AutoCompleteStringCollection stringColl2 = new AutoCompleteStringCollection();

                BusinessObjects.M_Product_BS p = new M_Product_BS();
                BusinessObjects.Sales_BM     s = new Sales_BM();

                List <M_Product_BS> PList = new List <M_Product_BS>();
                List <Sales_BM>     SList = new List <Sales_BM>();
                PList = p.GetProducts(con);
                SList = s.getSales(con);

                SalesList_Public = SList;



                foreach (M_Product_BS item in PList)
                {
                    //  stringColl.Add(item.ID.ToString());
                    stringColl.Add(item.name);
                }

                foreach (Sales_BM item in SList)
                {
                    stringColl2.Add(item.sales_id.ToString());
                }


                txtProductName.AutoCompleteCustomSource = stringColl;
                txtReceiptNo.AutoCompleteCustomSource   = stringColl2;
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "! System Error . Code 104. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 8
0
        private void autoComplete()
        {
            try
            {
                txtPID.AutoCompleteMode     = AutoCompleteMode.Suggest;
                txtPID.AutoCompleteSource   = AutoCompleteSource.CustomSource;
                txtPName.AutoCompleteMode   = AutoCompleteMode.Suggest;
                txtPName.AutoCompleteSource = AutoCompleteSource.CustomSource;

                AutoCompleteStringCollection stringColl  = new AutoCompleteStringCollection();
                AutoCompleteStringCollection stringColl2 = new AutoCompleteStringCollection();

                BusinessObjects.M_Product_BS cObj = new M_Product_BS();
                cObjList = cObj.GetProducts(con);
                Category_BS catObj = new Category_BS();
                catList = catObj.GetCategory(con);

                foreach (M_Product_BS item in cObjList)
                {
                    stringColl.Add(item.ID.ToString());
                    stringColl2.Add(item.name);
                }


                txtPID.AutoCompleteCustomSource   = stringColl;
                txtPName.AutoCompleteCustomSource = stringColl2;
                cmbPCat.DataSource = null;
                cmbPCat.DataSource = catList;

                cmbPCat.DisplayMember = "name";
                cmbPCat.ValueMember   = "ID";
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 9
0
        private void lnkSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtECost.Text) || string.IsNullOrEmpty(txtEPname.Text) || string.IsNullOrEmpty(txtEPrice.Text) ||
                    cmbECategory.SelectedIndex == -1)
                {
                    MetroMessageBox.Show(this, "Please enter valid data to the text fields", "System Warning!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (Convert.ToDecimal(txtEPrice.Text) < Convert.ToDecimal(txtECost.Text))
                {
                    MetroMessageBox.Show(this, "Unit Price should be higher than or equal to Unit Cost ", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);;
                }

                else
                {
                    int          pid      = 0;
                    M_Product_BS IndexObj = new M_Product_BS();
                    pid = Convert.ToInt32(txtEPid.Text);

                    string waran = "";
                    if (cmbMonth.Checked)
                    {
                        waran = " /Month";
                    }
                    else
                    {
                        waran = " /Week";
                    }


                    bool result = cObjList.Any();
                    if (result)
                    {
                        foreach (M_Product_BS item in cObjList)
                        {
                            if (item.ID == pid)
                            {
                                IndexObj.ID        = pid;
                                IndexObj.name      = txtEPname.Text;
                                IndexObj.unitPrice = Convert.ToDecimal(txtEPrice.Text);
                                //IndexObj.boundlePrice = Convert.ToDecimal(txtEBoundlePrice.Text);
                                IndexObj.cost     = Convert.ToDecimal(txtECost.Text);
                                IndexObj.catObj   = (BusinessObjects.Category_BS)cmbECategory.SelectedItem;
                                IndexObj.category = IndexObj.catObj.ID;
                                //IndexObj.boundleCost = Convert.ToDecimal(txtPackagecost.Text);
                                IndexObj.warranty = numericUpDown1.Value.ToString() + waran;

                                if (string.IsNullOrEmpty(txtDes.Text))
                                {
                                    IndexObj.description = "";
                                }
                                else
                                {
                                    IndexObj.description = txtDes.Text;
                                }
                            }
                        }

                        if (IndexObj.Update(con))
                        {
                            MetroMessageBox.Show(this, "Product data Successfully updated", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearText();
                            loadGrid();
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "Process encountered an error. Please try again", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        txtEPid.Enabled      = false;
                        txtEPname.Enabled    = false;
                        txtEPrice.Enabled    = false;
                        txtECost.Enabled     = false;
                        cmbECategory.Enabled = false;
                        //txtEBoundlePrice.Enabled = false;
                        lnkSearch.Enabled = false;
                        //txtPackagecost.Enabled = false;
                        txtDes.Enabled         = false;
                        numericUpDown1.Enabled = false;
                        txtDes.Text            = "Description";
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "Table is empty ", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }