public bool insertAndUpdate(CategoriesBLL c)
        {
            bool isSuccess = false;

            try
            {
                SqlCommand cmd = new SqlCommand("USP_InsertCategoriesDetails", AppManager.ConnectionManager);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("id", SqlDbType.Int).Value              = c.id;
                cmd.Parameters.Add("title", SqlDbType.VarChar).Value       = c.title;
                cmd.Parameters.Add("description", SqlDbType.VarChar).Value = c.description;
                cmd.Parameters.Add("added_date", SqlDbType.DateTime).Value = c.added_date;
                cmd.Parameters.Add("added_by", SqlDbType.Int).Value        = c.added_by;
                int row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(isSuccess);
        }
        public bool Delete(CategoriesBLL b)
        {
            bool isSuccess = false;

            SqlConnection con = new SqlConnection(this.connect.connection);

            try
            {
                string sql = "DELETE FROM [dbo].[tblcategories]" +
                             " WHERE id = @id";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@id", b.ID);
                con.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(isSuccess);
        }
示例#3
0
 public MainForm()
 {
     InitializeComponent();
     productBLL         = new ProductBLL();
     categoriesBLL      = new CategoriesBLL();
     txtId.ReadOnly     = true;
     txtCateId.ReadOnly = true;
 }
示例#4
0
        public bool Update(CategoriesBLL c)
        {
            bool isSuccess = false;

            //Creating SQL connection
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //Sql query to update
                String sql = "UPDATE tbl_categories SET title=@title,description=@description,added_date=@added_date,added_by=@added_by WHERE id=@id";

                //Sql command to pass the value on sql query
                SqlCommand cmd = new SqlCommand(sql, conn);

                //Passing the value using command
                cmd.Parameters.AddWithValue("@title", c.title);
                cmd.Parameters.AddWithValue("@description", c.description);
                cmd.Parameters.AddWithValue("@added_date", c.added_date);
                cmd.Parameters.AddWithValue("@added_by", c.added_by);
                cmd.Parameters.AddWithValue("@id", c.id);

                conn.Open();

                //Create int variable to count executing query
                int rows = cmd.ExecuteNonQuery();

                //Checking the count whether greater than 0 or not
                if (rows > 0)
                {
                    //Query successful
                    isSuccess = true;
                }
                else
                {
                    //Query failed
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }


            return(isSuccess);
        }
    protected void Categories_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        // Determine the PDF path for the category being deleted...
        int categoryID = Convert.ToInt32(e.Keys["CategoryID"]);

        CategoriesBLL categoryAPI = new CategoriesBLL();
        Northwind.CategoriesDataTable categories = categoryAPI.GetCategoryByCategoryID(categoryID);
        Northwind.CategoriesRow category = categories[0];

        if (category.IsBrochurePathNull())
            deletedCategorysPdfPath = null;
        else
            deletedCategorysPdfPath = category.BrochurePath;
    }
示例#6
0
        public bool Insert(CategoriesBLL c)
        {
            bool isSuccess = false;

            //Sql connection
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //Query to add new category
                String sql = "INSERT INTO tbl_categories (title,description,added_date,added_by) VALUES(@title,@description,@added_date,@added_by)";

                SqlCommand cmd = new SqlCommand(sql, conn);

                //Passing values through parameters
                cmd.Parameters.AddWithValue("@title", c.title);
                cmd.Parameters.AddWithValue("@description", c.description);
                cmd.Parameters.AddWithValue("@added_date", c.added_date);
                cmd.Parameters.AddWithValue("@added_by", c.added_by);

                //Open dtabase connection
                conn.Open();

                //creating a int variable to count Executing sql query
                int rows = cmd.ExecuteNonQuery();

                //Checking rows count
                if (rows > 0)
                {
                    //Query successfull
                    isSuccess = true;
                }
                else
                {
                    //Query Failed..
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
示例#7
0
        public bool Delete(CategoriesBLL c)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //Query to delete from database

                String sql = "DELETE FROM tbl_categories WHERE id=@id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                //Passing the values using command
                cmd.Parameters.AddWithValue("@id", c.id);

                //Open sql connection
                conn.Open();
                //Count Query Executing
                int rows = cmd.ExecuteNonQuery();
                //If the query is executed successfully, the value of rows will be greater than 0 else less than 0

                if (rows > 0)
                {
                    //Query Success
                    isSuccess = true;
                }
                else
                {
                    //Query failed
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }


            return(isSuccess);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        int categoryID = Convert.ToInt32(Request.QueryString["CategoryID"]);

        // Get information about the specified category
        CategoriesBLL categoryAPI = new CategoriesBLL();
        Northwind.CategoriesDataTable categories = categoryAPI.GetCategoryWithBinaryDataByCategoryID(categoryID);
        Northwind.CategoriesRow category = categories[0];

        // For new categories, images are JPGs...

        // Output HTTP headers providing information about the binary data
        Response.ContentType = "image/jpeg";

        // Output the binary data
        Response.BinaryWrite(category.Picture);
    }
        public bool Insert(CategoriesBLL b)
        {
            bool          isSuccess = false;
            SqlConnection con       = new SqlConnection(this.connect.connection);

            try
            {
                string sql = "INSERT INTO [dbo].[tblcategories]" +
                             "([title]" +
                             ",[description]" +
                             ",[addeddate]" +
                             ",[addedby])" +
                             "VALUES" +
                             "(@title," +
                             " @description," +
                             "@addeddate," +
                             "@addedby)";
                SqlCommand cmd = new SqlCommand(sql, con);

                cmd.Parameters.AddWithValue("@title", b.Title);
                cmd.Parameters.AddWithValue("@description", b.Description);
                cmd.Parameters.AddWithValue("@addeddate", b.AddedDate);
                cmd.Parameters.AddWithValue("@addedby", b.AddedBy);
                con.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(isSuccess);
        }
        public bool Update(CategoriesBLL b)
        {
            bool          isSuccess = false;
            SqlConnection con       = new SqlConnection(this.connect.connection);

            try
            {
                string sql = "UPDATE [dbo].[tblcategories]" +
                             "SET[title] = @title," +
                             "[description] = @description," +
                             "[addeddate] = @addeddate," +
                             "[addedby] = @addedby" +
                             "WHERE id =@id";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@title", b.Title);
                cmd.Parameters.AddWithValue("@description", b.Description);
                cmd.Parameters.AddWithValue("@addeddate", b.AddedDate);
                cmd.Parameters.AddWithValue("@addedby", b.AddedBy);
                con.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                con.Close();
            }
            return(isSuccess);
        }
        public bool delete(CategoriesBLL c)
        {
            bool isSuccess = false;

            try
            {
                SqlCommand cmd = new SqlCommand("USP_DeleteCategories", AppManager.ConnectionManager);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("id", SqlDbType.Int).Value = c.id;
                int row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(isSuccess);
        }
示例#12
0
 // GET: Admin/Categories
 public CategoriesController()
 {
     bll = new CategoriesBLL();
 }
    protected void Categories_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        // Reference the PictureUpload FileUpload
        FileUpload PictureUpload = (FileUpload)Categories.Rows[e.RowIndex].FindControl("PictureUpload");
        if (PictureUpload.HasFile)
        {
            // Make sure the picture upload is valid
            if (ValidPictureUpload(PictureUpload))
            {
                e.NewValues["picture"] = PictureUpload.FileBytes;
            }
            else
            {
                // Invalid file upload, cancel update and exit event handler
                e.Cancel = true;
                return;
            }
        }

        // Reference the RadioButtonList
        RadioButtonList BrochureOptions = (RadioButtonList)Categories.Rows[e.RowIndex].FindControl("BrochureOptions");

        // Get BrochurePath information about the record being updated
        int categoryID = Convert.ToInt32(e.Keys["CategoryID"]);

        CategoriesBLL categoryAPI = new CategoriesBLL();
        Northwind.CategoriesDataTable categories = categoryAPI.GetCategoryByCategoryID(categoryID);
        Northwind.CategoriesRow category = categories[0];

        if (BrochureOptions.SelectedValue == "1")
        {
            // Use current value for BrochurePath
            if (category.IsBrochurePathNull())
                e.NewValues["brochurePath"] = null;
            else
                e.NewValues["brochurePath"] = category.BrochurePath;
        }
        else if (BrochureOptions.SelectedValue == "2")
        {
            // Remove the current brochure (set it to NULL in the database)
            e.NewValues["brochurePath"] = null;
        }
        else if (BrochureOptions.SelectedValue == "3")
        {
            // Reference the BrochurePath FileUpload control
            FileUpload BrochureUpload = (FileUpload)Categories.Rows[e.RowIndex].FindControl("BrochureUpload");

            // Process the BrochureUpload
            bool cancelOperation = false;
            e.NewValues["brochurePath"] = ProcessBrochureUpload(BrochureUpload, out cancelOperation);

            e.Cancel = cancelOperation;
        }
        else
        {
            // Unknown value!
            throw new ApplicationException(string.Format("Invalid BrochureOptions value, {0}", BrochureOptions.SelectedValue));
        }

        if (BrochureOptions.SelectedValue == "2" || BrochureOptions.SelectedValue == "3")
        {
            // "Remember" that we need to delete the old PDF file
            if (category.IsBrochurePathNull())
                deletedCategorysPdfPath = null;
            else
                deletedCategorysPdfPath = category.BrochurePath;
        }
    }
        public void ProcessRequest(HttpContext context)
        {
            var json        = new StreamReader(context.Request.InputStream).ReadToEnd();
            var responseMsg = new Dictionary <string, string>();


            bool   isUpdate            = false;
            int    Records             = 0;
            int    AssignCategoryID    = 0;
            string TableName           = "";
            string Search              = "";
            string Order               = "";
            int    PageNumnber         = 0;
            var    _categoryobj        = new CategoriesBLL();
            var    _ld_categories_json = JsonConvert.DeserializeObject <Category_Struct_V2>(json);

            var _ld_post_data = new Dictionary <string, CategoryObject>();

            if ((context.Request.Params["action"] != null))
            {
                switch (context.Request.Params["action"])
                {
                case "process":

                    var cat = JsonConvert.DeserializeObject <Category_Struct_V2>(json);

                    isUpdate = false;
                    if (context.Request.Params["isupdate"] != null)
                    {
                        isUpdate = Convert.ToBoolean(context.Request.Params["isupdate"]);
                        isUpdate = true;
                    }

                    if (isUpdate)
                    {
                        CategoriesBLL.Process(cat, isUpdate);
                    }

                    context.Response.Write(responseMsg);
                    break;

                case "delete":
                    var _delcategory = JsonConvert.DeserializeObject <Category_Struct>(json);
                    if (context.Request.Params["assigncategoryid"] != null)
                    {
                        AssignCategoryID = Convert.ToInt32(context.Request.Params["assigncategoryid"]);
                        CategoriesBLL.Delete(_delcategory.ID, AssignCategoryID);
                    }
                    else
                    {
                        CategoriesBLL.Delete(_delcategory.ID);
                    }

                    break;

                // This update is only for pubplishing pending videos (unpublished videos only)
                case "update_category":

                    // Authentication
                    if (!context.User.Identity.IsAuthenticated)
                    {
                        responseMsg["status"]  = "error";
                        responseMsg["message"] = "Authentication Failed";
                        context.Response.Write(responseMsg);
                        return;
                    }
                    if (context.Request.Params["assigncategoryid"] != null)
                    {
                        AssignCategoryID = Convert.ToInt32(context.Request.Params["assigncategoryid"]);
                    }
                    if (context.Request.Params["tablename"] != null)
                    {
                        TableName = context.Request.Params["tablename"].ToString();
                    }


                    CategoriesBLL.Update_Category(JsonConvert.DeserializeObject <Category_Struct_V2>(json).CategoryID, AssignCategoryID, TableName);

                    responseMsg["status"]  = "success";
                    responseMsg["message"] = "Operation Commit";
                    context.Response.Write(responseMsg);
                    break;


                case "load_categories":

                    bool isAll = false;
                    if (context.Request.Params["isall"] != null)
                    {
                        isAll = Convert.ToBoolean(context.Request.Params["isall"]);
                    }
                    var _query = JsonConvert.DeserializeObject <Category_Struct_V2>(json);

                    var _lst_sm = CategoriesBLL.Load_CategoriesSummary(_query.CategoryID, _query.Type, isAll, _query.isPrivate, _query.Mode, "categoryname asc", _query.Records, 1);

                    var _vObject = new CategoryObject()
                    {
                        Data  = _lst_sm,
                        Count = CategoriesBLL.Count_CategoriesSummary(_query.Type, _query.isPrivate, _query.Mode)
                    };

                    context.Response.Write(_vObject);

                    break;

                case "fetch_category_names":

                    CategoriesBLL.Fetch_Category_Names(_ld_categories_json.Type);
                    responseMsg["status"] = "success";
                    //context.Response.Write(responseMsg);
                    break;
                }
            }
            else
            {
                // No action found
                responseMsg["status"]  = "error";
                responseMsg["message"] = "No action found";
                context.Response.Write(JsonConvert.SerializeObject(responseMsg));
            }
        }