コード例 #1
0
        protected void _DeleteButton_Command(object sender, CommandEventArgs e)
        {
            try
            {
                int      i = 0;
                CheckBox cb;
                int      id;
                DB.DB_Object.ClassTypeProduct objClassData = new DB.DB_Object.ClassTypeProduct();
                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.DeleteTypeProduct(id) == false)
                        {
                            CommonClass.MessageBox.Show("Lỗi không thể xóa phần loại sản phẩm này!");
                            return;
                        }
                    }
                    i++;
                }

                LoadGrid();
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.Message);
            }
        }
コード例 #2
0
        private void LoadGrid()
        {
            DB.DB_Object.ClassTypeProduct objData = new DB.DB_Object.ClassTypeProduct();
            DataTable dt = objData.getDataTypeProduct();

            _grid.DataSource = dt;
            _grid.DataBind();
        }
コード例 #3
0
        // Insert mới thông tin một News...
        private void Insert()
        {
            try
            {
                string 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;
                }

                string strPathImages1 = "~/Images/ImgNews/defaultimage.GIF";
                if (!string.IsNullOrEmpty(FileUpload2.FileName) && CheckExtention(FileUpload2) == true)
                {
                    Sycomore.UploadFile Upload = new Sycomore.UploadFile();
                    Upload.StrFileName = FileUpload2.FileName;
                    Upload.StrFolder   = Server.MapPath("~/Images/ImgNews/");
                    Upload.Upload(FileUpload2);
                    strPathImages1 = "~/Images/ImgNews/" + Upload.StrFileName;
                }

                string strPathImages2 = "~/Images/ImgNews/defaultimage.GIF";
                if (!string.IsNullOrEmpty(FileUpload3.FileName) && CheckExtention(FileUpload3) == true)
                {
                    Sycomore.UploadFile Upload = new Sycomore.UploadFile();
                    Upload.StrFileName = FileUpload3.FileName;
                    Upload.StrFolder   = Server.MapPath("~/Images/ImgNews/");
                    Upload.Upload(FileUpload3);
                    strPathImages2 = "~/Images/ImgNews/" + Upload.StrFileName;
                }

                string strTypeName = CommonClass.StringValidator.GetSafeString(txtName.Text.Trim());
                string strNameEL   = txtNameEL.Text.Trim();

                DB.DB_Object.ClassTypeProduct objClassData = new DB.DB_Object.ClassTypeProduct();
                if (objClassData.InsertTypeProduct(strTypeName, strPathImages, strPathImages1, strNameEL, strPathImages2) == true)
                {
                    Response.Redirect("~/Amincp/ManagerTypeProduct.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);
            }
        }
コード例 #4
0
        // Lấy thông tin theo tiêu chí tìm kiếm nhat định
        private void LoadGridSearch()
        {
            int KeyID = 0;

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

            string Name = CommonClass.StringValidator.GetSafeString(txtName.Text.Trim());

            DB.DB_Object.ClassTypeProduct objClassData = new DB.DB_Object.ClassTypeProduct();
            DataTable dt = objClassData.getDataSearchTypeProduct(KeyID, Name);

            lblTotalRows.Text = dt.Rows.Count.ToString();
            _grid.DataSource  = dt;
            _grid.DataBind();
        }
コード例 #5
0
        // Load thông tin tên loại tin tức lên các combox VN
        protected void LoadComBoBoxTypeProduct()
        {
            DB.DB_Object.ClassTypeProduct ClassNews = new DB.DB_Object.ClassTypeProduct();
            DataTable dt = ClassNews.getDataTypeProduct();

            if (dt != null)
            {
                ListItem Item = new ListItem();
                Item.Text  = "----- Chọn loại sản phẩm -----";
                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);
                }
            }
        }
コード例 #6
0
        private void LoadTextBox()
        {
            int intID = 0;

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

            DB.DB_Object.ClassTypeProduct objClassData = new DB.DB_Object.ClassTypeProduct();
            DataTable dt = objClassData.getDataEditTypeProduct(intID);

            foreach (DataRow dr in dt.Rows)
            {
                txtId.Text          = dr["ID"].ToString();
                txtName.Text        = dr["TypeName"].ToString();
                txtPathImages.Text  = dr["ImagePathOut"].ToString();
                txtPathImages1.Text = dr["ImagePathOver"].ToString();
                txtPathImages2.Text = dr["ImagePath"].ToString();
                txtNameEL.Text      = dr["TypeNameEL"].ToString();
            }
            // Visible cái fileUpload khi không cần thiết
            FileUpload1.Visible    = false;
            txtPathImages.Visible  = true;
            btChangeImages.Visible = true;

            // Visible cái fileUpload khi không cần thiết
            FileUpload2.Visible     = false;
            txtPathImages1.Visible  = true;
            btChangeImages1.Visible = true;

            // Visible cái fileUpload khi không cần thiết
            FileUpload3.Visible     = false;
            txtPathImages2.Visible  = true;
            btChangeImages2.Visible = true;
        }