Ejemplo n.º 1
0
        public List <HCM_Product> GetAllProducts()
        {
            List <HCM_Product> list_HcmProduct = new List <HCM_Product>();
            HCM_Product        hcm_Product_Obj = new HCM_Product();

            try
            {
                using (SqlConnection sql_obj = new SqlConnection())
                {
                    sql_obj.ConnectionString = sql_con.GetConnection();
                    sql_obj.Open();

                    using (SqlCommand sqlcmd_Obj = new SqlCommand("HCM_PROC_GetAllProducts", sql_obj))
                    {
                        sqlcmd_Obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_Obj.CommandTimeout = 0;
                        SqlDataAdapter da = new SqlDataAdapter(sqlcmd_Obj);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        sql_obj.Close();
                        if (dt.Rows.Count > 0)
                        {
                            for (var i = 0; i < dt.Rows.Count; i++)
                            {
                                hcm_Product_Obj                     = new HCM_Product();
                                hcm_Product_Obj.ProductID           = Convert.ToInt32(dt.Rows[i]["ProductID"]);
                                hcm_Product_Obj.ProductName         = Convert.ToString(dt.Rows[i]["ProductName"]);
                                hcm_Product_Obj.ProductDescription  = Convert.ToString(dt.Rows[i]["ProductDescription"]);
                                hcm_Product_Obj.Status              = Convert.ToBoolean(dt.Rows[i]["Status"]);
                                hcm_Product_Obj.CreatedAndUpdatedBy = Convert.ToInt32(HttpContext.Current.Session["UserID"]);
                                list_HcmProduct.Add(hcm_Product_Obj);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(list_HcmProduct);
        }
Ejemplo n.º 2
0
        public List <HCM_Product> GetActiveProducts()
        {
            List <HCM_Product> list_HcmProduct = new List <HCM_Product>();
            HCM_Product        hcm_Product_Obj = new HCM_Product();

            try
            {
                using (SqlConnection sql_obj = new SqlConnection())
                {
                    sql_obj.ConnectionString = sql_con.GetConnection();
                    sql_obj.Open();

                    using (SqlCommand sqlcmd_Obj = new SqlCommand("HCM_PROC_GetActiveProductsList", sql_obj))
                    {
                        sqlcmd_Obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_Obj.CommandTimeout = 0;
                        SqlDataAdapter da = new SqlDataAdapter(sqlcmd_Obj);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        sql_obj.Close();
                        if (dt.Rows.Count > 0)
                        {
                            for (var i = 0; i < dt.Rows.Count; i++)
                            {
                                hcm_Product_Obj             = new HCM_Product();
                                hcm_Product_Obj.ProductID   = Convert.ToInt32(dt.Rows[i]["ProductID"]);
                                hcm_Product_Obj.ProductName = Convert.ToString(dt.Rows[i]["ProductName"]);
                                list_HcmProduct.Add(hcm_Product_Obj);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(list_HcmProduct);
        }