Ejemplo n.º 1
0
        protected void _DeleteButton_Command(object sender, CommandEventArgs e)
        {
            try
            {
                int      i = 0;
                CheckBox cb;
                int      id;
                DB.DB_Object.ClassNews objClassData = new DB.DB_Object.ClassNews();
                foreach (DataGridItem dgi in _grid.Items)
                {
                    cb = (CheckBox)dgi.Cells[0].Controls[1];
                    if (cb.Checked)
                    {
                        // lấy Mã số của record cần xóa...
                        id = (int)_grid.DataKeys[i];
                        // gọi hàm xóa từng record...
                        if (objClassData.DeleteNews(id) == false)
                        {
                            CommonClass.MessageBox.Show("Lỗi không thể xóa. Yêu cầu kiểm tra lại hệ thống!");
                            return;
                        }
                    }
                    i++;
                }

                LoadGrid();
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.Message);
            }
        }
Ejemplo n.º 2
0
        // Load dữ lieu lên các TextBox tương ứng
        private void LoadTextBox()
        {
            int intID = 0;

            if (CommonClass.StringValidator.IsNumber(Request["NewsID"].ToString().Trim()))
            {
                intID = int.Parse(Request["NewsID"].ToString().Trim());
            }

            DB.DB_Object.ClassNews objClassData = new DB.DB_Object.ClassNews();
            DataTable dt = objClassData.getDataEditNews(intID);

            foreach (DataRow dr in dt.Rows)
            {
                txtTypeNewsID.Text           = dr["NewsID"].ToString();
                cboNameNewsVN.SelectedValue  = dr["TypeNewsID"].ToString();
                txtTitleNewsEL.Text          = dr["TitleNewsEL"].ToString();
                txtTitleNewsVN.Text          = dr["TitleNewsVN"].ToString();
                txtShortDescriptionEL.Text   = dr["ShortDescriptionEL"].ToString();
                txtShortDescriptionVN.Text   = dr["ShortDescriptionVN"].ToString();
                txtContentEL.Value           = dr["ContentEL"].ToString();
                txtContentVN.Value           = dr["ContentVN"].ToString();
                txtPathImages.Text           = dr["PathImages"].ToString();
                txtReadTimes.Text            = dr["ReadTimes"].ToString();
                chkTypeDisplay.SelectedValue = dr["TypeDisplay"].ToString();
            }

            // Visible cái fileUpload khi không cần thiết
            FileUpload1.Visible    = false;
            txtPathImages.Visible  = true;
            btChangeImages.Visible = true;
        }
Ejemplo n.º 3
0
 protected void cboNameNewsVN_SelectedIndexChanged(object sender, EventArgs e)
 {
     DB.DB_Object.ClassNews objClassTypeNews = new DB.DB_Object.ClassNews();
     if (objClassTypeNews.CheckMenuParent(cboNameNewsVN.SelectedValue))
     {
         CommonClass.MessageBox.Show("Không thể thêm tin tức vào Menu này. Yêu cầu chọn lại menu khác!");
         cboNameNewsVN.SelectedValue = "0";
     }
 }
Ejemplo n.º 4
0
        // Lấy toàn bộ thông tin từ trong table lên lưới
        private void LoadGrid()
        {
            DB.DB_Object.ClassNews objClassData = new DB.DB_Object.ClassNews();
            DataTable dt = objClassData.getDataNews();

            lblTotalRows.Text = dt.Rows.Count.ToString();
            _grid.DataSource  = dt;
            _grid.DataBind();
        }
Ejemplo n.º 5
0
        // Update mới thông tin một News...
        private void Update()
        {
            try
            {
                int    intNewsID             = int.Parse(txtTypeNewsID.Text.Trim());
                string strTitleNewsEL        = CommonClass.StringValidator.GetSafeString(txtTitleNewsEL.Text.Trim());
                string strTitleNewsVN        = CommonClass.StringValidator.GetSafeString(txtTitleNewsVN.Text.Trim());
                int    intTypeNewsID         = int.Parse(cboNameNewsVN.SelectedValue);
                string strShortDescriptionEL = CommonClass.StringValidator.GetSafeString(txtShortDescriptionEL.Text.Trim());
                string strShortDescriptionVN = CommonClass.StringValidator.GetSafeString(txtShortDescriptionVN.Text.Trim());
                string strContentEL          = objClassCommon.FilterSQLParamater(txtContentEL.Value);
                string strContentVN          = objClassCommon.FilterSQLParamater(txtContentVN.Value);
                string strPathImages         = txtPathImages.Text.Trim();
                int    intReadTimes          = Convert.ToInt32(txtReadTimes.Text);
                int    intTypeDisplay        = int.Parse(chkTypeDisplay.SelectedValue);

                //Khi Admin tiến hành đổi hình ảnh
                if (FileUpload1.Visible == true)
                {
                    strPathImages = "~/Images/ImgNews/defaultimage.GIF";
                    if (!string.IsNullOrEmpty(FileUpload1.FileName) && CheckExtention(FileUpload1) == true)
                    {
                        Sycomore.UploadFile Upload = new Sycomore.UploadFile();
                        Upload.StrFileName = FileUpload1.FileName;
                        Upload.StrFolder   = Server.MapPath("~/Images/ImgNews/");
                        Upload.Upload(FileUpload1);
                        strPathImages = "~/Images/ImgNews/" + Upload.StrFileName;
                    }
                }

                DB.DB_Object.ClassNews objClassData = new DB.DB_Object.ClassNews();
                if (objClassData.UpdateNews(intNewsID, strTitleNewsEL, strTitleNewsVN, intTypeNewsID, strShortDescriptionEL,
                                            strShortDescriptionVN, strContentEL, strContentVN, strPathImages, intReadTimes, intTypeDisplay) == true)
                {
                    Response.Redirect("~/Amincp/ManagerNews.aspx");
                }
                else
                {
                    CommonClass.MessageBox.Show("Lỗi kết nối đến Server. Vui lòng kiểm tra hệ thống mạng!");
                }
            }
            catch (Exception e)
            {
                SetErrorMessage(e.Message);
            }
        }
Ejemplo n.º 6
0
        // Load thông tin tên loại tin tức lên các combox VN
        protected void LoadComBoBoxTypeNewsVN()
        {
            DB.DB_Object.ClassNews ClassNews = new DB.DB_Object.ClassNews();
            DataTable dt = ClassNews.GetDataLoadComBoxVN();

            if (dt != null)
            {
                ListItem Item = new ListItem();
                Item.Text  = "----- Chọn ngành nghề -----";
                Item.Value = "0";
                cboNameNewsVN.Items.Add(Item);
                foreach (DataRow dr in dt.Rows)
                {
                    ListItem newItem = new ListItem();
                    newItem.Text  = dr[1].ToString();
                    newItem.Value = dr[0].ToString();
                    cboNameNewsVN.Items.Add(newItem);
                }
            }
        }
Ejemplo n.º 7
0
        // Lấy thông tin theo tiêu chí tìm kiếm nhat định
        private void LoadGridSearch()
        {
            int IsSelectAll = 0;

            int KeyID = 0;

            if (txtCritId.Text.Trim().Length > 0)
            {
                KeyID = int.Parse(txtCritId.Text.Trim());
            }

            string NameVN = CommonClass.StringValidator.GetSafeString(txtNameVN.Text.Trim());
            string NameEL = CommonClass.StringValidator.GetSafeString(txtNameEL.Text.Trim());


            DB.DB_Object.ClassNews objClassData = new DB.DB_Object.ClassNews();
            DataTable dt = objClassData.getDataSearchNews(IsSelectAll, KeyID, NameVN, NameEL);

            lblTotalRows.Text = dt.Rows.Count.ToString();
            _grid.DataSource  = dt;
            _grid.DataBind();
        }