Пример #1
0
        public string[] getWarranty(string connString, int pid)
        {
            try
            {
                string query = @"select warranty,name from _Product where  ID=" + pid + "";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();
                string[]      result = new string[2];
                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    BusinessObjects.M_Product_BS pObj = new BusinessObjects.M_Product_BS();

                    result[0] = reader[0].ToString();
                    result[1] = reader[1].ToString();
                }
                conn.Close();


                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public BusinessObjects.M_Product_BS Get1Product(string connString)
        {
            try
            {
                string query = @"select ID,name,unitPrice,cost,category,description,warranty from _Product where  name='" + name + "'";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();
                BusinessObjects.M_Product_BS pObj = new BusinessObjects.M_Product_BS();
                SqlDataReader reader = DBHelper.ReadData(query, conn);

                while (reader.Read())
                {
                    pObj.ID          = Convert.ToInt32(reader[0].ToString());
                    pObj.name        = reader[1].ToString();
                    pObj.unitPrice   = Convert.ToDecimal(reader[2].ToString());
                    pObj.cost        = Convert.ToDecimal(reader[3].ToString());
                    pObj.category    = Convert.ToInt32(reader[4].ToString());
                    pObj.description = reader[5].ToString();
                    pObj.warranty    = reader[6].ToString();
                }
                conn.Close();
                return(pObj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public List <BusinessObjects.M_Product_BS> GetProductsWithLikeQuery(string connString, string TypingText)
        {
            try
            {
                TypingText = "%" + TypingText + "%";


                List <BusinessObjects.M_Product_BS> ProductList = new List <BusinessObjects.M_Product_BS>();


                string query = "select ID,name,unitPrice,cost,category,description,warranty from _Product WHERE name LIKE '" + TypingText + "'";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();



                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    BusinessObjects.M_Product_BS pObj = new BusinessObjects.M_Product_BS();

                    pObj.ID        = Convert.ToInt32(reader[0].ToString());
                    pObj.name      = reader[1].ToString();
                    pObj.unitPrice = Convert.ToDecimal(reader[2].ToString());

                    pObj.cost     = Convert.ToDecimal(reader[3].ToString());
                    pObj.category = Convert.ToInt32(reader[4].ToString());

                    pObj.description = reader[5].ToString();
                    pObj.warranty    = reader[6].ToString();
                    ProductList.Add(pObj);
                }
                conn.Close();


                return(ProductList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public List <M_Product_BS> GetOutOfStockProducts(string connString)
        {
            try
            {
                List <BusinessObjects.M_Product_BS> ProductList = new List <BusinessObjects.M_Product_BS>();

                string query = @"select ID,name,unitPrice,cost,category,description,warranty from _Product where ID not in (select distinct(pid) from _stock_product)";


                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();

                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    BusinessObjects.M_Product_BS pObj = new BusinessObjects.M_Product_BS();

                    pObj.ID        = Convert.ToInt32(reader[0].ToString());
                    pObj.name      = reader[1].ToString();
                    pObj.unitPrice = Convert.ToDecimal(reader[2].ToString());

                    pObj.cost     = Convert.ToDecimal(reader[3].ToString());
                    pObj.category = Convert.ToInt32(reader[4].ToString());

                    pObj.description = reader[5].ToString();
                    pObj.warranty    = reader[6].ToString();
                    ProductList.Add(pObj);
                }
                conn.Close();


                return(ProductList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        public List <BusinessObjects.M_Product_BS> getProductByVat_ID(string connString, int catID)
        {
            try
            {
                List <BusinessObjects.M_Product_BS> ProductList = new List <BusinessObjects.M_Product_BS>();
                string query = @"select ID,name,unitPrice,cost,category,warranty from _Product where  category=" + catID + "";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();

                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    BusinessObjects.M_Product_BS pObj = new BusinessObjects.M_Product_BS();

                    pObj.ID        = Convert.ToInt32(reader[0].ToString());
                    pObj.name      = reader[1].ToString();
                    pObj.unitPrice = Convert.ToDecimal(reader[2].ToString());

                    pObj.cost     = Convert.ToDecimal(reader[3].ToString());
                    pObj.category = Convert.ToInt32(reader[4].ToString());

                    pObj.warranty = reader[5].ToString();



                    ProductList.Add(pObj);
                }
                conn.Close();


                return(ProductList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        private void lnkAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //if (string.IsNullOrEmpty(txtPCost.Text) || string.IsNullOrEmpty(txtProName.Text) || string.IsNullOrEmpty(txtPMPrice.Text) ||
                // cmbCategory.SelectedIndex == -1 ||string.IsNullOrEmpty(txtBundlePrice.Text) ||string.IsNullOrEmpty(txtpackagecost.Text)||string.IsNullOrEmpty(txtDescp.Text))

                if (string.IsNullOrEmpty(txtPCost.Text) || string.IsNullOrEmpty(txtProName.Text) || string.IsNullOrEmpty(txtPMPrice.Text) ||
                    cmbCategory.SelectedIndex == -1)


                {
                    MetroMessageBox.Show(this, "Please enter valid data to the text fields", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (Convert.ToDecimal(txtPMPrice.Text) < Convert.ToDecimal(txtPCost.Text))
                    {
                        MetroMessageBox.Show(this, "Unit Price should be higher than Unit Cost", "System Warning !", MessageBoxButtons.OK, MessageBoxIcon.Warning);;
                    }
                    //else if (Convert.ToDecimal(txtBundlePrice.Text) <= Convert.ToDecimal(txtpackagecost.Text))
                    //{
                    //    MetroMessageBox.Show(this, "Package Price should be higher than Package Cost", "System Warning !", MessageBoxButtons.OK, MessageBoxIcon.Warning); ;
                    //}
                    else
                    {
                        string name, description;

                        //decimal price, boundlePrice, cost, boundlecost;

                        decimal price, cost;
                        int     category;

                        name     = txtProName.Text;
                        category = Convert.ToInt32(cmbCategory.SelectedValue);
                        price    = Convert.ToDecimal(txtPMPrice.Text);
                        //boundlePrice = Convert.ToDecimal(txtBundlePrice.Text);
                        cost = Convert.ToDecimal(txtPCost.Text);
                        //boundlecost = Convert.ToDecimal(txtpackagecost.Text);

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

                        BusinessObjects.M_Product_BS BP = new BusinessObjects.M_Product_BS();
                        //BP.boundlePrice = boundlePrice;
                        BP.name      = name;
                        BP.category  = category;
                        BP.cost      = cost;
                        BP.unitPrice = price;
                        //BP.boundleCost = boundlecost;
                        BP.description = description;

                        if (cmbMonth.Checked)
                        {
                            BP.warranty = numericUpDown1.Value.ToString() + " /Month";
                        }
                        else
                        {
                            BP.warranty = numericUpDown1.Value.ToString() + " /Week";
                        }

                        if (BP.Add(con))
                        {
                            MetroMessageBox.Show(this, "Product data added Successfully", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearText();
                            getMaxId();
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "! Process encountered an error", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, " !System Error. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }