Exemplo n.º 1
0
        private void PictureBox1_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Bạn có chắc ngừng kinh doanh sản phẩm " + lblTenSP.Text + " này không?",
                                               "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (res == DialogResult.No)
            {
                return;
            }

            Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS();
            DTO_SanPham           SP  = bus.search_SANPHAM(lblMaSP.Text)[0];

            SP.TRANGTHAI = "Ngừng kinh doanh";
            if (bus.suaData(SP))
            {
                MessageBox.Show("Bạn đã cập nhật sản phẩm thành công");
            }
            else
            {
                MessageBox.Show("Có vấn đề xảy ra! Không thành công");
            }

            string str = txtTimKiem.Text;

            txtTimKiem.Text = "a";
            txtTimKiem.Text = str;
            HienThiTrang(current_Page);
            lblPage.Text      = current_Page + "/" + number_Page;
            lblTrangThai.Text = "Ngừng kinh doanh";
        }
        protected void grvDSProduct_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ChonSP")
            {
                string      maSP    = e.CommandArgument.ToString();
                DTO_SanPham sanPham = BUS_SanPham.LaySanPham(maSP);
                if (sanPham != null)
                {
                    txtMaSanPham.Text    = sanPham.MaSP;
                    txtTenSanPham.Text   = sanPham.TenSP;
                    txtThongTinSP.Text   = sanPham.ThongTin;
                    txtGiaTien.Text      = Convert.ToString(sanPham.GiaTien);
                    txtSoLuong.Text      = Convert.ToString(sanPham.SoLuongTonKho);
                    txtMaLoaiSP.Text     = sanPham.MaLoaiSP;
                    txtAnhMinhHoa.Text   = sanPham.AnhMinhHoa;
                    chkTrangThai.Checked = sanPham.TrangThai;
                }
            }
            if (e.CommandName == "XoaSP")
            {
                string maSP = e.CommandArgument.ToString();

                if (BUS_SanPham.XoaSanPham(maSP))
                {
                    Response.Write("<script>alert('Xóa sản phảm thành công');</script>");
                    LoadDSSanPham();
                }
                else
                {
                    Response.Write("<script>alert('Xóa sản phẩm thất bại');</script>");
                }
            }
        }
Exemplo n.º 3
0
        void XuatThongTinSP(DTO_SanPham SP)
        {
            lblTenSP.Text     = SP.TENSP;
            lblMaSP.Text      = SP.MASP;
            lblSoLuong.Text   = TranDateFormat.SubString(SP.SLUONG);
            lblTrangThai.Text = SP.TRANGTHAI;
            lblLoiNhuan.Text  = TranDateFormat.SubString(SP.LOINHUAN);
            lblGiaBan.Text    = TranDateFormat.SubString(SP.DONGIA);
            Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS();
            lblNCC.Text = bus.getTenNCC(SP.MANCC);
            string ma = lblMaSP.Text;

            if (System.IO.File.Exists(Application.StartupPath + "/HinhSanPham/" + ma + ".jpg"))
            {
                picAnhSP.Image = Image.FromFile(Application.StartupPath + "/HinhSanPham/" + ma + ".jpg");
            }
            else
            if (System.IO.File.Exists(Application.StartupPath + "/HinhSanPham/" + ma + ".png"))
            {
                picAnhSP.Image = Image.FromFile(Application.StartupPath + "/HinhSanPham/" + ma + ".png");
            }
            else
            {
                picAnhSP.Image = Image.FromFile(Application.StartupPath + "/HinhSanPham/None" + ".png");
            }
        }
Exemplo n.º 4
0
        public bool suaSanPham(DTO_SanPham tv)
        {
            try
            {
                // Ket noi
                connect.Open();

                // Query string
                string SQL = string.Format("UPDATE SANPHAM " +
                                           "SET TENSP= N'{1}', MANCC='{2}',DONGIA= {3} , LOINHUAN={4} , SLUONG={5},TRANGTHAI= N'{6}' " +
                                           "WHERE MASP='{0}' ",
                                           tv.MASP, tv.TENSP, tv.MANCC, tv.DONGIA, tv.LOINHUAN, tv.SLUONG, tv.TRANGTHAI);
                //MessageBox.Show(SQL);
                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
        protected void btnThem_Click(object sender, EventArgs e)
        {
            DTO_SanPham sp = new DTO_SanPham();

            sp.MaSP          = txtMaSanPham.Text;
            sp.TenSP         = txtTenSanPham.Text;
            sp.ThongTin      = txtThongTinSP.Text;
            sp.GiaTien       = Convert.ToInt32(txtGiaTien.Text);
            sp.SoLuongTonKho = Convert.ToInt32(txtSoLuong.Text);
            sp.MaLoaiSP      = txtMaLoaiSP.Text;
            sp.TrangThai     = Convert.ToBoolean(chkTrangThai.Checked);
            sp.AnhMinhHoa    = "chuaco.jpg";

            if (!(sp.MaSP == "" || sp.TenSP == "" || sp.ThongTin == "" || sp.GiaTien == null || sp.SoLuongTonKho == null || sp.MaLoaiSP == "" || sp.AnhMinhHoa == ""))
            {
                if (BUS_SanPham.ThemSanPham(sp))
                {
                    Response.Write("<script>alert('Thêm sản phẩm thành công')</script>");
                    LoadDSSanPham();
                }
                else
                {
                    Response.Write("<script>alert('Thêm sản phẩm  thất bại')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('Chưa nhập đủ thông tin')</script>");
            }
        }
Exemplo n.º 6
0
        public bool themSanPham(DTO_SanPham tv)// THẮNG
        {
            try
            {
                // Ket noi
                connect.Open();


                string SQL = string.Format("INSERT INTO SANPHAM (MASP, TENSP, MANCC, DONGIA, LOINHUAN, SLUONG,TRANGTHAI) " +
                                           "VALUES ('{0}', N'{1}', '{2}',{3}, {4}, {5}, N'{6}' )",
                                           tv.MASP, tv.TENSP, tv.MANCC, tv.DONGIA, tv.LOINHUAN, tv.SLUONG, tv.TRANGTHAI); // DỮ LIỆU NHẬP VÀO

                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
Exemplo n.º 7
0
        public DTO_SanPham[] search_SANPHAM(string st)
        {
            int       i         = 0;
            DataTable infotable = sp.timKiemSanPham(st);

            if (infotable.Rows.Count == 0)
            {
                DTO_SanPham[] temp = new DTO_SanPham[1];
                temp[0] = new DTO_SanPham(getThongTinSP(0, 0), getThongTinSP(1, 0), getThongTinSP(2, 0), getThongTinSP(3, 0), getThongTinSP(4, 0), getThongTinSP(5, 0), getThongTinSP(6, 0));
                return(temp);
            }
            DTO_SanPham[]     dtosp  = new DTO_SanPham[infotable.Rows.Count];
            DataRowCollection result = infotable.Rows;

            foreach (DataRow row in result)
            {
                string[] str = new string[9];
                for (int j = 0; j <= 6; j++)
                {
                    str[j] = row[j].ToString();
                }
                dtosp[i] = new DTO_SanPham(str[0], str[1], str[2], str[3], str[4], str[5], str[6]);
                i++;
            }
            return(dtosp);
        }
Exemplo n.º 8
0
 //DAL Update Hang
 public bool updateSanPham(DTO_SanPham hang)
 {
     try
     {
         _conn.Open();
         SqlCommand cmd = new SqlCommand();
         cmd.Connection  = _conn;
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = "[UpdateDataIntoTblHang]";
         cmd.Parameters.AddWithValue("maHang", hang.SP_MaHang);
         cmd.Parameters.AddWithValue("tenHang", hang.SP_TenHang);
         cmd.Parameters.AddWithValue("soLuong", hang.SP_SoLuong);
         cmd.Parameters.AddWithValue("dongiaNhap", hang.SP_DonGiaNhap);
         cmd.Parameters.AddWithValue("dongiaBan", hang.SP_DonGiaBan);
         cmd.Parameters.AddWithValue("hinhAnh", hang.SP_HinhAnh);
         cmd.Parameters.AddWithValue("ghiChu", hang.SP_GhiChu);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     finally
     {
         _conn.Close();
     }
     return(false);
 }
        public int update_sanpham(DTO_SanPham dto_sanpham)
        {
            int parameter = 9;

            string[] name   = new string[parameter];
            object[] values = new object[parameter];

            name[0] = "@idsanpham";
            name[1] = "@tensp";
            name[2] = "@idnhacungcap";
            name[3] = "@idloaihang";
            name[4] = "@dongianhap";
            name[5] = "@soluongcon";
            name[6] = "@soluongchocungcap";
            name[7] = "@mota";
            name[8] = "@ngungban";

            values[0] = dto_sanpham.idsanpham;
            values[1] = dto_sanpham.tensp;
            values[2] = dto_sanpham.idnhacungcap;
            values[3] = dto_sanpham.idloaihang;
            values[4] = dto_sanpham.dongianhap;
            values[5] = dto_sanpham.soluongcon;
            values[6] = dto_sanpham.soluongchocungcap;
            values[7] = dto_sanpham.mota;
            values[8] = dto_sanpham.ngungban;

            string sql = "update_sanpham";

            return(ketnoi.Execute(sql, name, values, parameter));
        }
Exemplo n.º 10
0
        public bool themSanPham(DTO_SanPham SP)
        {
            try
            {
                // Ket noi
                _conn.Open();
                // Query string
                string SQL = string.Format("INSERT INTO SANPHAM(TenSanPham,FileAnh,GiaBanSanPham,GiaMuaSanPham,TinhTrang,MaLoaiSanPham,SoLuong) VALUES(N'{0}',N'{1}','{2}','{3}','{4}','{5}','{6}')", SP.TENSANPHAM, SP.TENFILE, SP.GIABANSANPHAM, SP.GIAMUASANPHAM, SP.TINHTRANG, SP.MALOAISANPHAM, SP.SOLUONG);

                // Command
                SqlCommand cmd = new SqlCommand(SQL, _conn);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                _conn.Close();
            }
            return(false);
        }
Exemplo n.º 11
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            DAO_SanPham dao = new DAO_SanPham();
            DTO_SanPham sp  = new DTO_SanPham();

            sp.ID = id;
            if (sp.ID != 0)
            {
                dao.Delete(sp);
                tbTen.Text          = "";
                tbSoLuong.Text      = "";
                tbDonVi.Text        = "";
                dtpHanSuDung.Text   = DateTime.Now.ToString();
                dtpNgaySanXuat.Text = DateTime.Now.ToString();
                dtpNgayThem.Text    = DateTime.Now.ToString();
                HinhAnh             = "";
                tbDonGia.Text       = "";
                cbbDanhMuc.Text     = "";
                pictureBox1.Image   = null;
                FSanPham_Load(sender, e);
            }
            else
            {
            }
        }
Exemplo n.º 12
0
        private void CapNhat_Click(object sender, EventArgs e)
        {
            Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS();
            DTO_SanPham           SP  = new DTO_SanPham();

            SP.MASP      = lblMaSP.Text;
            SP.TENSP     = txtTenSP.Text;
            SP.DONGIA    = txtGiaBan.Text;
            SP.SLUONG    = txtSoLuong.Text;
            SP.MANCC     = MaNCC;
            SP.LOINHUAN  = txtLoiNhuan.Text;
            SP.TRANGTHAI = txtTrangThai.Text;
            if (!bus.suaData(SP))
            {
                PushNoti noti = new PushNoti("Error", "Có lỗi xảy ra! Sửa không thành công!");
                noti.Width  = this.Width;
                noti.Height = 30;
                this.Controls.Add(noti);
                noti.Show();
                noti.ShowNoti();
                return;
            }
            else
            {
                PushNoti noti1 = new PushNoti("Success", "Cập nhật thông tin thành công!");
                noti1.Width  = this.Width;
                noti1.Height = 30;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                //MessageBox.Show("Bạn đã cập nhật thành công");
            }
        }
Exemplo n.º 13
0
 //
 public static bool ChinhSuaSanPham(DTO_SanPham sp)
 {
     if (DAO_SanPham.KTSPTonTai(sp.MaSP))
     {
         return(DAO_SanPham.ChinhSuaSanPham(sp));
     }
     return(false);
 }
Exemplo n.º 14
0
 //
 public static bool ThemSanPham(DTO_SanPham sp)
 {
     if (!DAO_SanPham.KTSPTonTai(sp.MaSP))
     {
         return(DAO_SanPham.ThemSanPham(sp) == 1);
     }
     return(false);
 }
Exemplo n.º 15
0
        public List <DTO_SanPham> List()
        {
            List <DTO_SanPham> list  = new List <DTO_SanPham>();
            DataTable          table = Data.Instance.ExecuteQuery("select * from SanPham");

            foreach (DataRow row in table.Rows)
            {
                DTO_SanPham sp = new DTO_SanPham(row);
                list.Add(sp);
            }
            return(list);
        }
Exemplo n.º 16
0
        private void PicThemMoi_Click(object sender, EventArgs e)
        {
            Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS();
            DTO_SanPham           sp  = new DTO_SanPham();

            sp.MASP  = txtMaSP.Text;
            sp.TENSP = txtTenSP.Text;
            DTO_NhaCungCap[] ncc = bus.search_NhaCungCap(sp.TENSP);
            sp.MANCC     = ncc[0].MANCC;
            sp.DONGIA    = txtGiaBan.Text;
            sp.LOINHUAN  = txtLoiNhuan.Text;
            sp.SLUONG    = txtSoLuong.Text;
            sp.TRANGTHAI = txtTrangThai.Text;

            string error = CheckThongTin.check_Nhap(sp);

            if (error != "")
            {
                PushNoti noti1 = new PushNoti("Error", error);
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                return;
            }

            if (bus.themData(sp) == false)
            {
                PushNoti noti1 = new PushNoti("Error", "Có lỗi xảy ra, thêm không thành công!");
                noti1.Width  = this.Width;
                noti1.Height = 30;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                //MessageBox.Show("Bạn đã cập nhật thành công");
                return;
            }
            else
            {
            }
            string desAnh = Application.StartupPath + "/HinhSanPham/" + sp.MASP + ".jpg";

            if (fileAnh != "")
            {
                if (File.Exists(desAnh))
                {
                    File.Delete(desAnh);
                }
                File.Copy(fileAnh, desAnh);
            }
            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 17
0
        private void txt_them6_Click(object sender, EventArgs e)
        {
            if (txt_idsp6.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập ID sản phẩm");
            }
            else if (txt_tensp6.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập tên sản phẩm");
            }
            else if (txt_dongianhap6.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập đơn giá nhập");
            }
            else if (txt_soluongcon6.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập số lượng còn");
            }
            else if (txt_slccc6.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập số lượng chờ cung cấp");
            }
            else if (txt_mota61.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập mô tả");
            }
            else if (txt_nb6.TextLength == 0)
            {
                MessageBox.Show("Chưa nhập ngừng bán");
            }

            else
            {
                DTO_SanPham dto_sanpham = new DTO_SanPham();
                dto_sanpham.idsanpham         = txt_idsp6.Text;
                dto_sanpham.tensp             = txt_tensp6.Text;
                dto_sanpham.idnhacungcap      = cbb_idncc.Text;
                dto_sanpham.idloaihang        = cbb_idlh.Text;
                dto_sanpham.dongianhap        = txt_dongianhap6.Text;
                dto_sanpham.soluongcon        = txt_soluongcon6.Text;
                dto_sanpham.soluongchocungcap = txt_slccc6.Text;
                dto_sanpham.mota     = txt_mota61.Text;
                dto_sanpham.ngungban = txt_nb6.Text;

                BUS_SanPham bus_sanpham = new BUS_SanPham();
                bus_sanpham.insert_sanpham(dto_sanpham);

                //load_sanpham();
                Quan_Ly_Load(sender, e);
                reset_sanpham();
            }
        }
Exemplo n.º 18
0
        public DataTable Delete(DTO_SanPham sp)
        {
            DataTable table = new DataTable();

            if (CheckWithID(sp.ID))
            {
                table = Data.Instance.ExecuteQuery("proc_Delete_SanPham @id ", new object[] { sp.ID });
            }
            else
            {
            }
            return(table);
        }
        public int delete_sanpham(DTO_SanPham dto_sanpham)
        {
            int parameter = 1;

            string[] name   = new string[parameter];
            object[] values = new object[parameter];
            name[0]   = "@idsanpham";
            values[0] = dto_sanpham.idsanpham;

            string sql = "delete_sanpham";

            return(ketnoi.Execute(sql, name, values, parameter));
        }
Exemplo n.º 20
0
        public List <DTO_SanPham> ListSP()
        {
            DataTable          table = new DataTable();
            List <DTO_SanPham> list  = new List <DTO_SanPham>();

            table = Data.Instance.ExecuteQuery("select * from SanPham");
            foreach (DataRow item in table.Rows)
            {
                DTO_SanPham sp = new DTO_SanPham(item);
                list.Add(sp);
            }
            return(list);
        }
Exemplo n.º 21
0
        public List <DTO_SanPham> ListSP_DanhMuc_SanPham(long id)
        {
            DataTable          table = new DataTable();
            List <DTO_SanPham> list  = new List <DTO_SanPham>();

            table = Data.Instance.ExecuteQuery("proc_ListSP_DanhMuc_SanPham @id ", new object[] { id });
            foreach (DataRow item in table.Rows)
            {
                DTO_SanPham sp = new DTO_SanPham(item);
                list.Add(sp);
            }
            return(list);
        }
Exemplo n.º 22
0
        private void txt_xoa6_Click(object sender, EventArgs e)
        {
            DTO_SanPham dto_sanpham = new DTO_SanPham();

            dto_sanpham.idsanpham = txt_idsp6.Text;

            BUS_SanPham bus_sanpham = new BUS_SanPham();

            bus_sanpham.delete_sanpham(dto_sanpham);

            Quan_Ly_Load(sender, e);
            reset_sanpham();
        }
Exemplo n.º 23
0
        //
        public static DTO_SanPham ConverToDTO(DataRow dr)
        {
            DTO_SanPham sp = new DTO_SanPham();

            sp.MaSP          = dr["MaSP"].ToString();
            sp.TenSP         = dr["TenSP"].ToString();
            sp.ThongTin      = dr["ThongTin"].ToString();
            sp.GiaTien       = Int32.Parse(dr["GiaTien"].ToString());
            sp.SoLuongTonKho = Convert.ToInt32(dr["SoLuongTonKho"].ToString());
            sp.MaLoaiSP      = dr["MaLoaiSP"].ToString();
            sp.AnhMinhHoa    = dr["AnhMinhHoa"].ToString();
            sp.TrangThai     = bool.Parse(dr["TrangThai"].ToString());
            return(sp);
        }
Exemplo n.º 24
0
        public DataTable Update(DTO_SanPham sp)
        {
            DataTable table = new DataTable();

            if (CheckWithID(sp.ID))
            {
                table = Data.Instance.ExecuteQuery("proc_Update_SanPham  @id , @ten , @soluong , @dovi , @ngaythem , @ngaysx , @han , @hinhanh , @gia , @id2 ",
                                                   new object[] { sp.ID, sp.Tensanpham, sp.Soluong, sp.Donvi, sp.Ngaythem, sp.Ngaysanxuat, sp.Hansudung, sp.Hinhanh, sp.Gia, sp.DanhmucID });
            }
            else
            {
            }
            return(table);
        }
Exemplo n.º 25
0
        public DataTable Insert(DTO_SanPham sp)
        {
            DataTable table = new DataTable();

            if (Check(sp.Tensanpham))
            {
            }
            else
            {
                table = Data.Instance.ExecuteQuery("proc_Insert_SanPham @ten , @soluong , @dovi , @ngaythem , @ngaysx , @han , @hinhanh , @gia , @id ",
                                                   new object[] { sp.Tensanpham, sp.Soluong, sp.Donvi, sp.Ngaythem, sp.Ngaysanxuat, sp.Hansudung, sp.Hinhanh, sp.Gia, sp.DanhmucID });
            }
            return(table);
        }
Exemplo n.º 26
0
        //
        public static bool ChinhSuaSanPham(DTO_SanPham sanPham)
        {
            string query = "UPDATE TaiKhoan SET TenSP=@TenSP, ThongTin=@ThongTin, GiaTien=@GiaTien, SoLuongTonKho=@SoLuongTonKho, MaLoaiSP = @MaLoaiSP, AnhMinhHoa=@AnhMinhHoa, TrangThai=@TrangThai WHERE MaSP=@MaSP";

            SqlParameter[] param = new SqlParameter[8];
            param[0] = new SqlParameter("@MaSP", sanPham.MaSP);
            param[1] = new SqlParameter("@TenSP", sanPham.TenSP);
            param[2] = new SqlParameter("@ThongTin", sanPham.ThongTin);
            param[3] = new SqlParameter("@GiaTien", sanPham.GiaTien);
            param[4] = new SqlParameter("@SoLuongTonKho", sanPham.SoLuongTonKho);
            param[5] = new SqlParameter("@MaLoaiSP", sanPham.MaLoaiSP);
            param[6] = new SqlParameter("@AnhMinhHoa", sanPham.AnhMinhHoa);
            param[7] = new SqlParameter("@TrangThai", sanPham.TrangThai);
            return(DataProvider.ExecuteUpdateQuery(query, param) == 1);
        }
        private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            if (txbTenSanPham.Text == "" || txbGiaBan.Text == "" || txbGiaMua.Text == "" || txbSoLuong.Text == "" || cbxLoaiSP.SelectedIndex == -1)
            {
                MessageBox.Show("Xin nhập vào không đầy đủ!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            //kiểm tra các trường dữ liệu đầu vào
            if (txbGiaBan.Text.All(char.IsDigit) == false || txbGiaBan.Text.All(char.IsDigit) == false || Int32.Parse(txbGiaBan.Text) < 0 || Int32.Parse(txbGiaMua.Text) < 0)
            {
                MessageBox.Show("Giá tiền không hợp lệ!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                txbGiaBan.Text = txbGiaMua.Text = "";
                return;
            }

            if (Int32.Parse(txbGiaBan.Text) < Int32.Parse(txbGiaMua.Text))
            {
                MessageBox.Show("Giá bán phải lớn hơn giá mua!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (txbSoLuong.Text.All(char.IsDigit) == false || Int32.Parse(txbSoLuong.Text) < 0)
            {
                MessageBox.Show("Số lượng không hợp lệ!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                txbSoLuong.Text = "";
                return;
            }

            if (imgLoc2 == "")
            {
                MessageBox.Show("Vui lòng chọn ảnh!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            int loaiSanPham;

            Int32.TryParse(cbxLoaiSP.SelectedValue.ToString(), out loaiSanPham);
            DTO_SanPham SP = new DTO_SanPham(0, txbTenSanPham.Text, imgLoc2, Int32.Parse(txbGiaBan.Text), Int32.Parse(txbGiaMua.Text), 1, loaiSanPham, Int32.Parse(txbSoLuong.Text));

            if (BUS_SP.themSanPham(SP))
            {
                MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                cleanWindow();
            }
            else
            {
                MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string masp = Request.QueryString["masp"];

            if (!BUS_SanPham.KTSPTonTai(masp))
            {
                Response.Redirect("Shop_Product.aspx");
            }
            else
            {
                DTO_SanPham sp = BUS_SanPham.LaySanPham(masp);
                imgAnhMinhHoa.ImageUrl = "images/shop/" + sp.AnhMinhHoa;
                lblTenSP.Text          = sp.TenSP;
                lblGiaTien.Text        = sp.GiaTien + "$";
            }
        }
Exemplo n.º 29
0
        //
        public static int ThemSanPham(DTO_SanPham sanPham)
        {
            string query = "INSERT INTO SanPham(MaSP,TenSP,ThongTin,GiaTien,SoLuongTonKho,MaLoaiSP,AnhMinhHoa,TrangThai)"
                           + "VALUES (@MaSP,@TenSP,@ThongTin,@GiaTien,@SoLuongTonKho,@MaLoaiSP,@AnhMinhHoa,@TrangThai)";

            SqlParameter[] param = new SqlParameter[8];
            param[0] = new SqlParameter("@MaSP", sanPham.MaSP);
            param[1] = new SqlParameter("@TenSP", sanPham.TenSP);
            param[2] = new SqlParameter("@ThongTin", sanPham.ThongTin);
            param[3] = new SqlParameter("@GiaTien", sanPham.GiaTien);
            param[4] = new SqlParameter("@SoLuongTonKho", sanPham.SoLuongTonKho);
            param[5] = new SqlParameter("@MaLoaiSP", sanPham.MaLoaiSP);
            param[6] = new SqlParameter("@AnhMinhHoa", sanPham.AnhMinhHoa);
            param[7] = new SqlParameter("@TrangThai", sanPham.TrangThai);
            return(DataProvider.ExecuteInsertQuery(query, param));
        }
Exemplo n.º 30
0
        static public string check_Nhap(DTO_SanPham sp)
        {
            string error = "";

            Stelia_BUS.Stelia_BUS bus     = new Stelia_BUS.Stelia_BUS();
            DTO_SanPham[]         sanpham = bus.search_SANPHAM(sp.MASP);
            if (sanpham[0].MASP == sp.MASP)
            {
                error += "Mã sản phẩm này đã tồn tại";
            }
            if (Double.Parse(sanpham[0].DONGIA) < 0)
            {
                error += " " + "Giá sản phẩm phải > 0 ";
            }
            if (Double.Parse(sanpham[0].SLUONG) < 0)
            {
                error += " " + "Số lượng phải > 0 ";
            }
            return(error);
        }