Example #1
0
        private List <BusinessObjects.Stock> Get0StockList(string connString)
        {
            try
            {
                List <BusinessObjects.Stock> ProductList = new List <BusinessObjects.Stock>();
                string query = "select stock_id,sup_name, s_date,invoice_no from _Stokc";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();

                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    BusinessObjects.Stock pObj = new BusinessObjects.Stock();
                    pObj.stock_id   = Convert.ToInt32(reader[0].ToString());
                    pObj.sup_name   = reader[1].ToString();
                    pObj.s_date     = Convert.ToDateTime(reader[2].ToString());
                    pObj.invoice_no = reader[3].ToString();


                    //retreiving relevant stock_product detail based on stock id
                    BusinessObjects.stock_product sp = new stock_product();
                    sp.stock_id           = pObj.stock_id;
                    pObj.StockProductList = sp.Get_stock_by_sid(connString);
                    ProductList.Add(pObj);
                }
                conn.Close();


                return(ProductList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        private void btnAddStockItem_Click(object sender, EventArgs e)
        {
            //try
            //{
            int    checkloop      = 0;
            int    prodID         = 0;
            int    quntyToAddList = 0;
            string prName         = "";

            string col1 = "";

            foreach (DataGridViewRow dr in tblProduct.Rows)
            {
                //if (dr.Cells[4].Value != null || dr.Cells[4].Value!=string.Empty && dr.Cells[3].Value != null || dr.Cells[3].Value != string.Empty)
                if (dr.Cells[4].Value != null && dr.Cells[3].Value != null)
                {
                    checkloop++;
                    decimal priceTyped = 0;

                    col1 = dr.Cells[4].Value.ToString();


                    prodID         = Convert.ToInt32(dr.Cells[0].Value.ToString());
                    priceTyped     = Convert.ToDecimal(dr.Cells[3].Value.ToString());//getting teh price
                    quntyToAddList = Convert.ToInt32(dr.Cells[4].Value.ToString());
                    prName         = dr.Cells[1].Value.ToString();

                    int  check  = 0;
                    bool result = stock_product_list.Any();

                    if (result)
                    {
                        foreach (stock_product item in stock_product_list)
                        {
                            if (item.pid == prodID)
                            {
                                item.quantity = item.quantity + quntyToAddList;
                                item.price    = priceTyped;
                                check         = 1;
                            }
                        }
                    }


                    if (check == 0)
                    {
                        stock_product Stock_product = new BusinessObjects.stock_product();

                        Stock_product.pid      = prodID;
                        Stock_product.p_name   = prName;
                        Stock_product.price    = priceTyped;//adding the price
                        Stock_product.quantity = quntyToAddList;

                        Stock_product.stock_id = Convert.ToInt32(txtStockID.Text.ToString());

                        stock_product_list.Add(Stock_product);


                        //    }

                        //}
                    }
                    else
                    {
                        check = 0;
                    }
                }
            }


            if (checkloop > 0)
            {
                foreach (DataGridViewRow dr in tblProduct.Rows)
                {
                    //   dr.Cells[4].Value = string.Empty;

                    dr.Cells[4].Value = null;
                }


                //MessageBox.Show("Products were added");
                PopupNotifier pop = new PopupNotifier();
                pop.ContentText = "Products were added";
                pop.TitleText   = "Notification";
                // pop.Image = Resources.Button_Icon_Orange_svg; // or Image.FromFile(--Path--)
                pop.IsRightToLeft     = false;
                pop.ContentHoverColor = Color.Blue;
                pop.Popup();
            }
            else
            {
                foreach (DataGridViewRow dr in tblProduct.Rows)
                {
                    //dr.Cells[4].Value = string.Empty;
                    dr.Cells[4].Value = null;
                }

                //MessageBox.Show("No Products were added");

                PopupNotifier pop = new PopupNotifier();
                pop.ContentText = "No products were added";
                pop.TitleText   = "Notification";
                // pop.Image = Resources.Button_Icon_Orange_svg; // or Image.FromFile(--Path--)
                pop.IsRightToLeft     = false;
                pop.ContentHoverColor = Color.Blue;
                pop.Popup();
            }

            //}
            //catch (Exception ex)
            //{

            //    MetroMessageBox.Show(this, ex.Message, "System Error!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            //}
        }
Example #3
0
        private void tblProduct_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int rw  = e.RowIndex;
                int cl  = e.ColumnIndex;
                int pid = 0;


                if (cl == 5)
                {
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType().Name == "View_Dercription")
                        {
                            MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    pid = Convert.ToInt32(tblProduct.Rows[rw].Cells[0].Value.ToString());
                    string desc = "";
                    foreach (M_Product_BS item in cObjList)
                    {
                        if (item.ID == pid)
                        {
                            desc = item.description;
                        }
                    }
                    using (View_Dercription m = new View_Dercription(desc))
                    {
                        m.Show(this);
                    }

                    return;
                }

                else if (cl == 6)
                {
                    pid = Convert.ToInt32(tblProduct.Rows[rw].Cells[0].Value.ToString());

                    if (tblProduct.Rows[rw].Cells[4].Value == null)
                    {
                        MessageBox.Show("Please enter quanity");
                        return;
                    }
                    if (tblProduct.Rows[rw].Cells[3].Value == null)
                    {
                        MessageBox.Show("Cost should not be null");
                        return;
                    }


                    int  check  = 0;
                    bool result = stock_product_list.Any();

                    if (result)
                    {
                        foreach (stock_product item in stock_product_list)
                        {
                            if (item.pid == pid)
                            {
                                item.price    = Convert.ToDecimal(tblProduct.Rows[rw].Cells[3].Value.ToString());
                                item.quantity = item.quantity + Convert.ToInt32(tblProduct.Rows[rw].Cells[4].Value.ToString());
                                check         = 1;
                            }
                        }
                    }


                    if (check == 0)
                    {
                        foreach (M_Product_BS item in cObjList)
                        {
                            if (item.ID == pid)
                            {
                                stock_product Stock_product = new BusinessObjects.stock_product();

                                Stock_product.pid    = item.ID;
                                Stock_product.p_name = item.name;

                                Stock_product.price    = Convert.ToDecimal(tblProduct.Rows[rw].Cells[3].Value.ToString());
                                Stock_product.quantity = Convert.ToInt32(tblProduct.Rows[rw].Cells[4].Value.ToString());

                                Stock_product.stock_id = Convert.ToInt32(txtStockID.Text.ToString());

                                stock_product_list.Add(Stock_product);
                                MessageBox.Show("Product Added");
                            }
                        }
                    }
                    else
                    {
                        check = 0;
                    }


                    ////this is to testing purpose
                    //foreach (stock_product item in stock_product_list)
                    //    {

                    //        MessageBox.Show(item.p_name + " "+ item.quantity.ToString());
                    //    }
                }
                else
                {
                    return;
                }
            }

            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.Message, "System Error!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }