Пример #1
0
        //Select All Brand
        public List <Ent_Brand> SelectBrandList(int brandId)
        {
            List <Ent_Brand> result = new List <Ent_Brand>();
            Ent_Brand        ent    = new Ent_Brand();

            try
            {
                using (SqlCommand cmd = new SqlCommand("EC_Selectbrand", con))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Brand_ID", brandId));
                    IDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ent            = new Ent_Brand();
                        ent.Brand_ID   = Convert.ToInt32(dr["Brand_ID"]);
                        ent.Brand_Name = Convert.ToString(dr["Brand_Name"]);
                        result.Add(ent);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertException(ex.Message, "SelectCategoryList", brandId);
            }
            finally
            {
                con.Close();
            }
            return(result);
        }
Пример #2
0
        public int DeleteBrand(int Brand_ID)
        {
            Ent_Brand ent = new Ent_Brand();

            ent.Brand_ID = Brand_ID;

            //HttpCookie UserID = Request.Cookies["User_ID"];
            //var UserId = UserID != null ? UserID.Value.Split('=')[1] : "";
            //ent.Modified_By = Convert.ToInt32(UserId);
            ent.Modified_By = 1;
            DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime indiTime   = Convert.ToDateTime(indianTime.ToString("yyyy-MM-dd h:m:s"));

            ent.Modified_Date = indiTime;
            SafeTransaction trans = new SafeTransaction();
            int             i     = balMaster.DeleteBrand(ent, trans);

            if (i > 0)
            {
                trans.Commit();
            }
            else
            {
                trans.Rollback();
            }

            return(i);
        }
Пример #3
0
        public int DeleteBrand(Ent_Brand ent, SafeTransaction trans)
        {
            int dataResult;

            try
            {
                Dal_Master dal = new Dal_Master();
                dataResult = dal.DeleteBrand(ent, trans);
                return(dataResult);
            }
            catch
            {
                return(-1);
            }
        }
Пример #4
0
        public int SaveBrand(Ent_Brand entGuest, SafeTransaction trans)
        {
            int dataResult = 0;

            try
            {
                Dal_Master dal = new Dal_Master();
                dataResult = dal.SaveBrand(entGuest, trans);
                return(dataResult);
            }
            catch
            {
                return(0);
            }
        }
Пример #5
0
        // GET: Category
        public int SaveBrand(Ent_Brand model)
        {
            SafeTransaction trans      = new SafeTransaction();
            DateTime        indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime        indiTime   = Convert.ToDateTime(indianTime.ToString("yyyy-MM-dd h:m:s"));

            model.Created_Date = indiTime;
            HttpCookie C_UserID = Request.Cookies["User_ID"];
            string     User_ID  = C_UserID != null?C_UserID.Value.Split('=')[1] : "";

            model.Created_By = Convert.ToInt32(User_ID);
            int i = balMaster.SaveBrand(model, trans);

            if (i > 0)
            {
                trans.Commit();
            }
            else
            {
                trans.Rollback();
            }

            return(i);
        }
Пример #6
0
        public int DeleteBrand(Ent_Brand ent, SafeTransaction trans)
        {
            int dataResult  = 0;
            int dataresult1 = 0;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                using (SqlCommand cmd = new SqlCommand("EC_DeleteBrand", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Brand_ID", ent.Brand_ID));
                    cmd.Parameters.Add(new SqlParameter("@Modified_By", ent.Modified_By));
                    cmd.Parameters.Add(new SqlParameter("@Modified_Date", ent.Modified_Date));
                    try
                    {
                        dataResult = Convert.ToInt32(cmd.ExecuteScalar());
                        cmd.Dispose();
                    }
                    catch (Exception e)
                    {
                        InsertException(e.Message, "DeleteBrand", ent.Brand_ID);
                        dataResult = -1;
                    }
                }

                if (dataResult > 0)
                {
                    using (SqlCommand cmd = new SqlCommand("EC_InsertLog", trans.DatabaseConnection, trans.Transaction))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@Created_By", ent.Modified_By));
                        cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Modified_Date));
                        cmd.Parameters.Add(new SqlParameter("@Primary_Id", ent.Brand_ID));
                        cmd.Parameters.Add(new SqlParameter("@Log_Action", "Delete Brand"));
                        cmd.Parameters.Add(new SqlParameter("@Log_Status", "Admin"));
                        try
                        {
                            dataresult1 = Convert.ToInt32(cmd.ExecuteScalar());
                            if (dataresult1 > 0)
                            {
                                cmd.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            dataresult1 = -2;
                        }
                    }
                }
            }
            catch (Exception)
            {
                dataResult = -1;
            }
            finally
            {
                con.Close();
            }
            return(dataResult);
        }
Пример #7
0
        public int SaveBrand(Ent_Brand ent, SafeTransaction trans)
        {
            int dataresult  = 0;
            int dataresult1 = 0;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                //Insert To category Main Table
                using (SqlCommand cmd = new SqlCommand("EC_InsertBrand", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Brand_ID", ent.Brand_ID));
                    cmd.Parameters.Add(new SqlParameter("@Brand_Name", ent.Brand_Name));
                    cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Created_Date));
                    cmd.Parameters.Add(new SqlParameter("@Created_By", ent.Created_By));
                    try
                    {
                        dataresult = Convert.ToInt32(cmd.ExecuteScalar());
                        if (dataresult > 0)
                        {
                            cmd.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        //General gl = new General();
                        //gl.UpdateErrorLog(Ex, "CreateDietPlan");

                        dataresult = -2;
                        InsertException(ex.Message, "SaveBrand", ent.Brand_ID);
                    }
                }

                if (dataresult > 0)
                {
                    using (SqlCommand cmd = new SqlCommand("EC_InsertLog", trans.DatabaseConnection, trans.Transaction))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@Created_By", ent.Created_By));
                        cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Created_Date));
                        cmd.Parameters.Add(new SqlParameter("@Primary_Id", dataresult));
                        if (ent.Brand_ID > 0)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Log_Action", "Update Brand"));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Log_Action", "Insert Brand"));
                        }
                        cmd.Parameters.Add(new SqlParameter("@Log_Status", "Admin"));
                        try
                        {
                            dataresult1 = Convert.ToInt32(cmd.ExecuteScalar());
                            if (dataresult1 > 0)
                            {
                                cmd.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            dataresult1 = -2;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dataresult1 = -2;
            }
            finally { con.Close(); }

            return(dataresult);
        }