Esempio n. 1
0
        private void cmbPCat_SelectedIndexChanged(object sender, EventArgs e)
        {
            try{
                if (checkSelectedIndexChange)
                {
                    Category_BS cat = new Category_BS();
                    cat = (Category_BS)cmbPCat.SelectedItem;
                    // MessageBox.Show(cat.ID.ToString());
                    List <GetProductStock> ListItem = new List <GetProductStock>();
                    GetProductStock        lObj     = new GetProductStock();
                    ListItem = lObj.getProdAlongWithStockQuantity_ByCatID(con, cat.ID);

                    loadGrid(ListItem);



                    checkSelectedIndexChange = false;
                }
                else
                {
                    checkSelectedIndexChange = false;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void lnkOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtCategory.Text))
                {
                    MetroMessageBox.Show(this, "Please enter valid data to the text fields", "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Category_BS CBS  = new Category_BS();
                string      name = txtCategory.Text;

                CBS.name = name;


                if (CBS.Add(con))
                {
                    MetroMessageBox.Show(this, "Successfully Saved", "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MetroMessageBox.Show(this, "System error", "MetroMessageBox", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System error  " + ex.Message, "MetroMessageBox", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        private void cmbECategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (checkSelectedIndexChange)
                {
                    Category_BS cat = (Category_BS)cmbECategory.SelectedItem;

                    Sales_BM sale = new Sales_BM();

                    List <Sales_BM> saleList = new List <Sales_BM>();
                    saleList = sale.getSalesByCatID(con, cat.ID);

                    loadGrid(saleList);

                    checkSelectedIndexChange = false;
                }
                else
                {
                    checkSelectedIndexChange = false;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
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. 5
0
        private void cmbECategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (checkSelectedIndexChange)
                {
                    Category_BS  cat        = (Category_BS)cmbECategory.SelectedItem;
                    Stock        stock      = new Stock();
                    List <Stock> stockList2 = new List <Stock>();
                    stockList2 = stock.GetOneStockByCatID(con, cat.ID);


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

                    foreach (Stock item in stockList2)
                    {
                        tblProduct.Rows.Add();
                        tblProduct.Rows[i].Cells[0].Value = item.stock_id;
                        tblProduct.Rows[i].Cells[1].Value = item.invoice_no;

                        tblProduct.Rows[i].Cells[2].Value = item.sup_name;

                        tblProduct.Rows[i].Cells[3].Value = item.s_date.ToString();


                        foreach (Stock stock2 in StockList)
                        {
                            if (item.stock_id == stock2.stock_id)
                            {
                                tblProduct.Rows[i].Cells[4].Value = stock2.StockProductList.Count;
                            }
                        }

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

                        tblProduct.Rows[i].Cells[6].Value = "View";


                        i++;
                    }
                    checkSelectedIndexChange = false;
                }
                else
                {
                    checkSelectedIndexChange = false;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Init()
        {
            // In danh sach category
            this.category_bs = new Category_BS();
            List <string> category_list = this.category_bs.get_category();

            this.CategoryList.DataSource = category_list;

            //In toan bo sach
            this.book_bs = new Book_BS();
            DataTable book_data = this.book_bs.get_all_book();

            this.BookTable.DataSource = book_data;
        } // Khoi tao du lieu
Esempio n. 7
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. 8
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. 9
0
        private void cmbECategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (checkSelectedIndexChange)
                {
                    Category_BS     cat        = (Category_BS)cmbECategory.SelectedItem;
                    Purchase        stock      = new Purchase();
                    List <Purchase> stockList2 = new List <Purchase>();
                    stockList2 = stock.GetPurchaseByCatID(con, cat.ID);


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

                    foreach (Purchase item in stockList2)
                    {
                        tblProduct.Rows.Add();
                        tblProduct.Rows[i].Cells[0].Value = item.stock_id;
                        tblProduct.Rows[i].Cells[1].Value = item.invoice_no;

                        tblProduct.Rows[i].Cells[2].Value = item.sup_name;

                        tblProduct.Rows[i].Cells[3].Value = item.s_date.ToString();
                        tblProduct.Rows[i].Cells[4].Value = item.grandTotal;
                        tblProduct.Rows[i].Cells[5].Value = "View";



                        i++;
                    }
                    checkSelectedIndexChange = false;
                }
                else
                {
                    checkSelectedIndexChange = false;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
        private void cmbPCat_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //DateTime sDate = DateTime.ParseExact(dateStart.ToString(), "yyyy/MM/dd", null);
                //DateTime eDate = DateTime.ParseExact(dateEnd.ToString(), "yyyy/MM/dd", null);



                if (checkSelectedIndexChange)
                {
                    //DateTime sDate = Convert.ToDateTime(dateStart.Text);

                    //DateTime eDate = Convert.ToDateTime(dateEnd.Text);


                    DateTime    sDate = DateTime.ParseExact(dateStart.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    DateTime    eDate = DateTime.ParseExact(dateEnd.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    Category_BS cat   = new Category_BS();
                    cat = (Category_BS)cmbPCat.SelectedItem;



                    List <GetProductStock> ListItem = new List <GetProductStock>();

                    GetProductStock lObj = new GetProductStock();

                    //MessageBox.Show(cat.ID.ToString());
                    ListItem = lObj.getProdAlongWithSalesQuantity_ByCatID(con, cat.ID, sDate, eDate);
                    checkSelectedIndexChange = false;
                    loadGrid(ListItem);
                }
                else
                {
                    checkSelectedIndexChange = false;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 11
0
        private void cmbPCat_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (checkSelectedIndexChange)
                {
                    Category_BS cat = (Category_BS)cmbPCat.SelectedItem;
                    int         i   = 0;
                    tblProduct.Rows.Clear();


                    foreach (M_Product_BS item in cObjList)
                    {
                        if (item.catObj == cat)
                        {
                            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++;
                        }
                    }
                    checkSelectedIndexChange = false;
                }
                else
                {
                    checkSelectedIndexChange = false;
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 12
0
 private void loadGrid()
 {
     try
     {
         BusinessObjects.Category_BS        cObj     = new Category_BS();
         List <BusinessObjects.Category_BS> cObjList = new List <Category_BS>();
         cObjList = cObj.GetCategory(con);
         int i = 0;
         grdCategory.Rows.Clear();
         foreach (Category_BS item in cObjList)
         {
             grdCategory.Rows.Add();
             grdCategory.Rows[i].Cells[0].Value = item.ID;
             grdCategory.Rows[i].Cells[1].Value = item.name;
             i++;
         }
     }
     catch (Exception ex)
     {
         MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 13
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);
            }
        }