Ejemplo n.º 1
0
        public static bool UpdateProductCategory(ProductCategory_DTO category)
        {
            SqlConnection con = DataProvider.OpenConnection();
            SqlCommand    cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_updateProductCategory]", con);

            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter p = new SqlParameter("@ProductCategoryID", category.ProductCategoryID);
                cmd.Parameters.Add(p);
                p = new SqlParameter("@ProductCategoryName", category.ProductCategoryName);
                cmd.Parameters.Add(p);
                p = new SqlParameter("@PercentRevenue", category.PercentRevenue);
                cmd.Parameters.Add(p);

                cmd.ExecuteNonQuery();
                DataProvider.CloseConnection(con);
                return(true);
            }
            catch
            {
                DataProvider.CloseConnection(con);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void btnUpdateCategory_Click(object sender, EventArgs e)
        {
            try
            {
                ProductCategory_DTO category = new ProductCategory_DTO();
                category.ProductCategoryID   = dtgvCategoryInfoList.CurrentRow.Cells["ProductCategoryID"].Value.ToString();
                category.ProductCategoryName = txtCategoryName.Text;
                category.PercentRevenue      = float.Parse(txtPercentRevenue.Text);

                if (txtCategoryID.Text == "" || txtCategoryName.Text == "" || txtPercentRevenue.Text == "")
                {
                    XtraMessageBox.Show("You have to choose at least one category to update!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ClearDisplay();
                    return;
                }

                if (ProductCategory_BUS.UpdateProductCategory(category))
                {
                    XtraMessageBox.Show("Category Info has been updated sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadCategoryList();
                    ClearDisplay();
                    return;
                }
            }
            catch
            {
                XtraMessageBox.Show("Update Info Failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 3
0
        private void btnInsertCategory_Click(object sender, EventArgs e)
        {
            try
            {
                ProductCategory_DTO category = new ProductCategory_DTO();
                category.ProductCategoryID   = txtCategoryID.Text;
                category.ProductCategoryName = txtCategoryName.Text;
                category.PercentRevenue      = float.Parse(txtPercentRevenue.Text);

                if (txtCategoryID.Text == "" || txtCategoryName.Text == "" || txtPercentRevenue.Text == "")
                {
                    XtraMessageBox.Show("You have to fullfill category information!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ClearDisplay();
                    return;
                }

                if (ProductCategory_BUS.InsertProductCategory(category))
                {
                    XtraMessageBox.Show("Category Info has been inserted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadCategoryList();
                    ClearDisplay();
                    return;
                }
            }
            catch
            {
                XtraMessageBox.Show("Insert Info Failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 4
0
        public static bool DeleteProductCategory(ProductCategory_DTO category)
        {
            SqlConnection con = DataProvider.OpenConnection();
            SqlCommand    cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_deleteProductCategory]", con);

            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter p = new SqlParameter("@ProductCategoryID", category.ProductCategoryID);
                cmd.Parameters.Add(p);

                cmd.ExecuteNonQuery();
                DataProvider.CloseConnection(con);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DataProvider.CloseConnection(con);
                return(false);
            }
        }
Ejemplo n.º 5
0
        public static List <ProductCategory_DTO> LoadProductCategory()
        {
            SqlConnection con = DataProvider.OpenConnection();
            SqlCommand    cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_getProductCategory]", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.ExecuteNonQuery();
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;

            DataTable dt = new DataTable();

            da.Fill(dt);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            List <ProductCategory_DTO> listCategory = new List <ProductCategory_DTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ProductCategory_DTO category = new ProductCategory_DTO();
                category.ProductCategoryID   = dt.Rows[i]["ProductCategoryID"].ToString();
                category.ProductCategoryName = dt.Rows[i]["ProductCategoryName"].ToString();
                category.PercentRevenue      = float.Parse(dt.Rows[i]["PercentRevenue"].ToString());

                listCategory.Add(category);
            }

            DataProvider.CloseConnection(con);
            return(listCategory);
        }
Ejemplo n.º 6
0
 public static bool DeleteProductCategory(ProductCategory_DTO category)
 {
     return(ProductCategory_DAL.DeleteProductCategory(category));
 }
Ejemplo n.º 7
0
 public static bool UpdateProductCategory(ProductCategory_DTO category)
 {
     return(ProductCategory_DAL.UpdateProductCategory(category));
 }
Ejemplo n.º 8
0
 public static bool InsertProductCategory(ProductCategory_DTO category)
 {
     return(ProductCategory_DAL.InsertProductCategory(category));
 }