예제 #1
0
 //insert hang hoa
 public bool InsertHangHoa(DTO_HangHoa a)
 {
     try
     {
         HangHoa insert      = new HangHoa();
         Binary  file_binary = new Binary(a.img);
         insert.MaThuongHieu = a.MaThuongHieu;
         insert.MaLoai       = a.MaLoai;
         insert.TenHang      = a.TenHang;
         insert.DonGiaNhap   = a.DonGiaNhap;
         insert.DonGiaBan    = a.DonGiaBan;
         insert.SoluongTon   = a.SoluongTon;
         insert.DVT          = a.DVT;
         insert.MoTa         = a.MoTa;
         insert.HinhAnh      = file_binary;
         insert.Size         = a.Size;
         insert.MauSac       = a.MauSac;
         insert.FileNam      = a.Filename;
         db.HangHoas.InsertOnSubmit(insert);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public UI_ThemHangHoa(DTO_HangHoa obj)
 {
     InitializeComponent();
     strMaHangHoa            = obj.MaHangHoa;
     txtTenHangHoa.Text      = obj.TenHangHoa;
     txtTenModel.Text        = obj.TenModel;
     txtGiaBan.Text          = obj.GiaBan.ToString();
     txtGiamGia.Text         = obj.GiamGia.ToString();
     txtDonViTinh.Text       = obj.DonViTinh;
     txtMoTa.Text            = obj.MoTa;
     txtXuatXu.Text          = obj.XuatXu;
     txtThoiGianBaoHanh.Text = obj.ThoiGianBaoHang.ToString();
     txtThongSoKiThuat.Text  = obj.ThongSoKyThuat;
     iSoLuongTon             = (int)obj.SoLuongTon;
     bTrangThai = (bool)obj.TrangThai;
     if (obj.HinhAnh != null)
     {
         imageHangHoa.Source = new BitmapImage(new Uri(obj.HinhAnh));
     }
     isNew = false;
     loadCombobox();
     foreach (DTO_LoaiHangHoa item in BUS_LoaiHangHoa.showData())
     {
         if (item.TenLoaiHangHoa.Equals(obj.TenLoaiHangHoa))
         {
             cbLoaiHangHoa.SelectedValue = item.MaLoaiHangHoa;
             break;
         }
     }
 }
예제 #3
0
 //Update Hang Hoa
 public bool UpdateHangHoa(DTO_HangHoa a)
 {
     try
     {
         Binary  file_binary = new Binary(a.img);
         HangHoa update      = db.HangHoas.Where(p => p.MaHang == a.MaHang).SingleOrDefault();
         update.MaThuongHieu = a.MaThuongHieu;
         update.MaLoai       = a.MaLoai;
         update.TenHang      = a.TenHang;
         update.DonGiaNhap   = a.DonGiaNhap;
         update.DonGiaBan    = a.DonGiaBan;
         update.SoluongTon   = a.SoluongTon;
         update.DVT          = a.DVT;
         update.MoTa         = a.MoTa;
         update.HinhAnh      = file_binary;
         update.Size         = a.Size;
         update.MauSac       = a.MauSac;
         update.FileNam      = a.Filename;
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #4
0
        public bool update(DTO_HangHoa obj)
        {
            using (CellphoneComponentEntities db = new CellphoneComponentEntities())
            {
                var resultMaLoaiHangHoa = db.Database
                                          .SqlQuery <String>("select MaLoaiHangHoa from dbo.LoaiHangHoa where TenLoaiHangHoa = N'" + obj.TenLoaiHangHoa + "'")
                                          .FirstOrDefault();
                HangHoa hanghoa = new HangHoa();
                hanghoa.MaHangHoa       = obj.MaHangHoa;
                hanghoa.TenHangHoa      = obj.TenHangHoa;
                hanghoa.GiaBan          = obj.GiaBan;
                hanghoa.GiamGia         = obj.GiamGia;
                hanghoa.SoLuongTon      = obj.SoLuongTon;
                hanghoa.DonViTinh       = obj.DonViTinh;
                hanghoa.MoTa            = obj.MoTa;
                hanghoa.ThongSoKyThuat  = obj.ThongSoKyThuat;
                hanghoa.XuatXu          = obj.XuatXu;
                hanghoa.ThoiGianBaoHang = obj.ThoiGianBaoHang;
                hanghoa.HinhAnh         = obj.HinhAnh;
                hanghoa.MaLoaiHangHoa   = resultMaLoaiHangHoa;
                hanghoa.TrangThai       = obj.TrangThai;
                hanghoa.TenModel        = obj.TenModel;

                db.HangHoas.Attach(hanghoa);
                db.Entry(hanghoa).State = System.Data.Entity.EntityState.Modified;
                if (db.SaveChanges() > 0)
                {
                    return(true);
                }
                return(false);
            }
        }
        private void btn_Sua_Click(object sender, EventArgs e)
        {
            byte[]      b  = ImageToByteArray(pct_HinhAnh.Image);
            DTO_HangHoa hh = new DTO_HangHoa(int.Parse(txtMaHang.Text), int.Parse(cboTH.Text), int.Parse(cboLoai.Text),
                                             txtTenHang.Text, int.Parse(txtGiaNhap.Text), int.Parse(txtDonGiaBan.Text), int.Parse(txtSLT.Text), cboDVT.Text, txtMoTa.Text, b, cbo_Size.Text, txtMauSac.Text, txtFileImage.Text);

            bs_hh.UpdateHangHoa(hh);
            XtraMessageBox.Show("Sửa thành công.");
            LoadData();
        }
예제 #6
0
        private void onChangeMount(object sender, SelectionChangedEventArgs e)
        {
            DTO_HangHoa goods = cbbGoodsName.SelectedItem as DTO_HangHoa;

            if (goods != null && cbbReportYear.Text != "" && cbbReportMonth.Text != "")
            {
                txtImportMount.Text = BUS_BaoCaoTonKho.getImport(goods.MaHangHoa, Int32.Parse(cbbReportMonth.Text), Int32.Parse(cbbReportYear.Text)).ToString();
                txtFirstMount.Text  = BUS_BaoCaoTonKho.getFirstMount(goods.MaHangHoa).ToString();
                txtExportMount.Text = BUS_BaoCaoTonKho.getExport(goods.MaHangHoa, Int32.Parse(cbbReportMonth.Text), Int32.Parse(cbbReportYear.Text)).ToString();
                txtLastMount.Text   = BUS_BaoCaoTonKho.getLastMount(goods.MaHangHoa, Int32.Parse(cbbReportMonth.Text), Int32.Parse(cbbReportYear.Text)).ToString();
            }
            //txtSumMoney.Text = BUS_PhieuChi.Instance.sumMoneyPC(phieuNhap.MaPhieuNhap).ToString();
        }
예제 #7
0
        public List <DTO_HangHoa> DanhSachHangHoaID(int IDNhomHang)
        {
            List <DTO_HangHoa> tablelist = new List <DTO_HangHoa>();
            string             sTruyVan  = string.Format(@"SELECT * FROM [CF_HangHoa] WHERE [IDNhomHang] = {0}", IDNhomHang);
            DataTable          data      = new DataTable();

            data = DataProvider.TruyVanLayDuLieu(sTruyVan);
            foreach (DataRow item in data.Rows)
            {
                DTO_HangHoa table = new DTO_HangHoa(item);
                tablelist.Add(table);
            }
            return(tablelist);
        }
예제 #8
0
 //Delete Hang Hoa
 public bool DeleteHangHoa(DTO_HangHoa a)
 {
     try
     {
         HangHoa delete = db.HangHoas.Where(p => p.MaHang == a.MaHang).SingleOrDefault();
         db.HangHoas.DeleteOnSubmit(delete);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 private void btn_Them_Click(object sender, EventArgs e)
 {
     try
     {
         byte[]      b  = ImageToByteArray(pct_HinhAnh.Image);
         DTO_HangHoa hh = new DTO_HangHoa(int.Parse(cboTH.SelectedValue.ToString()), int.Parse(cboLoai.SelectedValue.ToString()), txtTenHang.Text,
                                          int.Parse(txtGiaNhap.Text), int.Parse(txtDonGiaBan.Text), int.Parse(txtSLT.Text), cboDVT.Text, txtMoTa.Text, b, cbo_Size.Text, txtMauSac.Text, txtFileImage.Text);
         bs_hh.InsertHangHoa(hh);
         XtraMessageBox.Show("Thêm thành công.");
         LoadData();
     }
     catch
     {
         XtraMessageBox.Show("Thêm thất bại.");
     }
 }
예제 #10
0
 private void btnEdit_Click(object sender, RoutedEventArgs e)
 {
     if (dgvHangHoa.SelectedItem != null)
     {
         DTO_HangHoa obj = new DTO_HangHoa();
         obj = dgvHangHoa.SelectedItem as DTO_HangHoa;
         if (obj.TrangThai == true)
         {
             UserControl usc = new UI_ThemHangHoa(dgvHangHoa.SelectedItem as DTO_HangHoa);
             UI_ManHinhChinh.gridMain.Children.Clear();
             UI_ManHinhChinh.gridMain.Children.Add(usc);
         }
         else
         {
             MessageBox.Show("Mặt hàng đã ngừng kinh doanh!");
         }
     }
 }
예제 #11
0
        //
        //sua
        //
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                DTO_HangHoa sv = new DTO_HangHoa(txtMaHH.Text, txtTenHH.Text, txtDVT.Text);

                BUS_HangHoa.Sua_hh(sv);
                DialogResult dr = MessageBox.Show("Sua thanh Cong", "Thông Báo", MessageBoxButtons.OK);
                loaddata();
                if (dr == DialogResult.OK)
                {
                    loaddata();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sua không thành công!\n" + ex.Message);
            }
        }
예제 #12
0
 private void guna2Button1_Click(object sender, EventArgs e)
 {
     txtMaHang.Text = BUS_HangHoa.Intance.loadMaHH();
     if (check == true)
     {
         check          = !check;
         btnSua.Enabled = false;
         btnXoa.Enabled = false;
         btnThem.Text   = "Lưu";
         resetData();
         txtTenHang.Enabled = true;
         txtTenHang.Focus();
         cbbDVT.Enabled     = true;
         txtSoLuong.Enabled = true;
         txtGiaBan.Enabled  = true;
         txtGiaGoc.Enabled  = true;
     }
     else
     {
         if (KiemTraNhap())
         {
             check          = !check;
             btnSua.Enabled = true;
             btnXoa.Enabled = true;
             btnThem.Text   = "Thêm";
             DTO_HangHoa data = new DTO_HangHoa();
             data.MaHang  = txtMaHang.Text;
             data.TenHang = txtTenHang.Text;
             data.SoLuong = int.Parse(txtSoLuong.Text);
             data.GiaBan  = int.Parse(txtGiaBan.Text);
             data.GiaGoc  = int.Parse(txtGiaGoc.Text);
             data.DonVi   = cbbDVT.SelectedValue.ToString();
             if (BUS_HangHoa.Intance.temHH(data, imgLocation))
             {
                 MessageBox.Show("Thêm Thành Công");
                 imgLocation = Application.StartupPath + "\\Resources\\hanghoa.png";
                 resetData();
                 cbbDVT.SelectedValue = dgvHangHoa.Rows[0].Cells["DonVi"].Value;
                 loadData();
             }
         }
     }
 }
예제 #13
0
        private void calSoLuongNhap(DTO_ChiTietPhieuBanHang item, bool isDelete = false)
        {
            var soLuong = BUS_HangHoa.Instance.getSoLuong(item.TenHangHoa);

            if (isDelete)
            {
                soLuong = soLuong + (int)item.SoLuong;
            }
            else
            {
                soLuong = soLuong - (int)item.SoLuong;
            }

            var hangHoa = new DTO_HangHoa();

            hangHoa.TenHangHoa = item.TenHangHoa;
            hangHoa.SoLuongTon = soLuong;
            BUS_HangHoa.Instance.UpdateSoLuong(hangHoa);
        }
 private void btn_Xoa_Click(object sender, EventArgs e)
 {
     try
     {
         DTO_HangHoa hh   = new DTO_HangHoa(int.Parse(txtMaHang.Text));
         bool        bien = bs_hh.DeleteHangHoa(hh);
         if (bien)
         {
             XtraMessageBox.Show("Xóa thành công.");
             LoadData();
         }
         else
         {
             XtraMessageBox.Show("Sản phẩm tồn tại trong CTHD.");
         }
     }
     catch
     {
         XtraMessageBox.Show("Xóa thất bại.");
     }
 }
예제 #15
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     if (dgvHangHoa.SelectedItem != null)
     {
         DTO_HangHoa obj = new DTO_HangHoa();
         obj = dgvHangHoa.SelectedItem as DTO_HangHoa;
         if (obj.TrangThai == true)
         {
             MessageBoxResult result = MessageBox.Show("Bạn muốn ngừng kinh doanh mặt hàng này?", "Confirmation", MessageBoxButton.YesNo);
             if (result == MessageBoxResult.Yes)
             {
                 BUS_HangHoa.Delete(obj);
                 dgvHangHoa.ItemsSource = BUS_HangHoa.showData();
             }
         }
         else
         {
             BUS_HangHoa.Delete(obj);
             dgvHangHoa.ItemsSource = BUS_HangHoa.showData();
         }
     }
 }
예제 #16
0
 public bool InsertHangHoa(DTO_HangHoa a)
 {
     return(dalhh.InsertHangHoa(a));
 }
예제 #17
0
 public bool DeleteHangHoa(DTO_HangHoa a)
 {
     return(dalhh.DeleteHangHoa(a));
 }
예제 #18
0
 public static bool Delete(DTO_HangHoa obj)
 {
     return(HangHoa.Instance.DeleteHH(obj));
 }
예제 #19
0
 public bool Insert(DTO_HangHoa obj)
 {
     return(HangHoa.Instance.InsertHH(obj));
 }
예제 #20
0
 public bool UpdateSoLuong(DTO_HangHoa obj)
 {
     return(HangHoa.Instance.updateSoLuong(obj));
 }
예제 #21
0
 //them
 //sua
 //xoa
 public static void Them_hh(DTO_HangHoa nv)
 {
     DAO_HangHoa.Themhanghoa(nv);
 }
예제 #22
0
 public static void Sua_hh(DTO_HangHoa nv)
 {
     DAO_HangHoa.Suahanghoa(nv);
 }
예제 #23
0
 //SUA
 public static void Suahanghoa(DTO_HangHoa gv)
 {
     con = DAO_KetNoiDB.OpenConnect();
     SqlHelper.ExecuteNonQuery(con, "PR_SUA_HH", gv.MaHH, gv.TenHH, gv.DVT);
     DAO_KetNoiDB.CloseConnect(con);
 }
예제 #24
0
 public bool UpdateHangHoa(DTO_HangHoa a)
 {
     return(dalhh.UpdateHangHoa(a));
 }