示例#1
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }
            try
            {
                int i = 0;
                CategoryTypeImpl obj = new CategoryTypeImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var status = (CheckBox)row.Cells[2].FindControl("StatusCheck");

                    if (status.Checked)
                    {
                        int ID = int.Parse(grvView.DataKeys[i].Value.ToString());
                        obj.Delete(ID);
                        //
                        DeleteCache(ID);
                    }

                    i++;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
            BindGird();
            //search(Convert.ToInt32(ddlNewType.Text), txtTim.Text.Trim());
            //        BindGird(int.Parse(ddlNewType.Text), 0);
        }
示例#2
0
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;

                CategoryTypeImpl obj = new CategoryTypeImpl();
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    try
                    {
                        userID = int.Parse(Request.QueryString["ID"]);


                        CategoryTypeInfo item = obj.GetInfo(userID);

                        if (item == null)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        else
                        {
                            item.s_CategoryName = txtName.Text;
                            obj.Update(item);

                            //reset cache
                            DeleteCache(item.pk_ID);
                        }
                    }
                    catch
                    {
                        Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                        return;
                    }
                }
                else
                {
                    CategoryTypeInfo item = new CategoryTypeInfo();
                    item.s_CategoryName = txtName.Text;

                    obj.Insert(item);

                    //reset cache
                    DeleteCache(item.pk_ID);
                }
                Response.Redirect("newtype_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Tên loại tin đã tồn tại. Bạn chạy chọn một tên khác";
            }
        }
示例#3
0
        private void BindGird()
        {
            try
            {
                CategoryTypeImpl obj = new CategoryTypeImpl();
                var dt = obj.GetAllCategory();

                //dt.DefaultView.Sort = sortString;

                grvView.DataSource = dt;
                grvView.DataBind();

                ltThongBao.Text = "<font color='red'>Có " + dt.Count + " loại tin được tìm thấy.</font>";
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
        }
示例#4
0
        private void EditData()
        {
            try
            {
                CategoryTypeImpl obj  = new CategoryTypeImpl();
                CategoryTypeInfo item = obj.GetInfo(int.Parse(Request.QueryString["ID"]));

                if (item == null)
                {
                    Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                    return;
                }
                else
                {
                    txtName.Text = item.s_CategoryName;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
        }