Exemplo n.º 1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     Data.Instance.DeleteSanPham(_sp);
     foreach (var v in _sp.link_image)
     {
         Picture.DeletePicture_by_ID(v);
     }
     MessageBox.Show("Xóa thành công!");
     _par.LoadDS();
 }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (toDo == "sua")
            {
                MessageBox.Show("Sua thanh cong!");
                return;
            }
            if (index == 0)
            {
                MoTa_click();
                index++;
                return;
            }
            else if (index == 1)
            {
                HinhAnh_click();
                index++;
                return;
            }
            if (!checkFill())
            {
                MessageBox.Show("Bạn cần điền đủ thông tin!");
                return;
            }
            string _loaisp;

            switch (txtLoaiSP.Text)
            {
            case "Màn Hình":
            {
                _loaisp = "ManHinh";
                break;
            }

            case "Bàn Phím":
            {
                _loaisp = "BanPhim";
                break;
            }

            case "Ổ Cứng":
            {
                _loaisp = "OCung";
                break;
            }

            case "USB":
            {
                _loaisp = "USB";
                break;
            }

            case "Chuột":
            {
                _loaisp = "Chuot";
                break;
            }

            case "Tản Nhiệt":
            {
                _loaisp = "TanNhiet";
                break;
            }

            default:
            {
                _loaisp = "Khac";
                break;
            }
            }
            s.setData(this.txtMaSP.Text, this.txtTenSP.Text, _loaisp, this.txtDVT.Text, this.txtXuatXu.Text, this.txtNhaSX.Text,
                      Int32.Parse(this.txtSoLuong.Text), Int32.Parse(this.txtGiaBan.Text), this.indexMota, "0:0:0",
                      "chua kiem duyet", parent._ID_me, 0, 0, 0);
            List <string> listmota = new List <string>();

            foreach (object ob in listObject)
            {
                if (ob is BunifuTextBox)
                {
                    BunifuTextBox txt = (BunifuTextBox)ob;
                    listmota.Add(txt.Text);
                }
            }
            if (toDo == "them")
            {
                Data.Instance.UpSanPham(s, linkPicture, linkPictureMoTa, listmota);
                MessageBox.Show("Đăng bán sản phẩm thành công!!\n " +
                                "Sản phẩm sẽ được duyệt và bán!!");
            }

            if (toDo == "sua")
            {
                MessageBox.Show("Sửa thành công !!");
                foreach (var v in s.link_image)
                {
                    Picture.DeletePicture_by_ID(v);
                }
                Data.Instance.FixSanPham(s, linkPicture);
                parent.LoadDS();
                this.Close();
            }
            foreach (Control c in this.Controls)
            {
                if (c is TextBox)
                {
                    c.Text = "";
                }
            }
        }