コード例 #1
0
ファイル: FrmThuCUng.cs プロジェクト: babychoi1999/ThucTapCM
        private void chonhinhanh(object sender, EventArgs e)
        {
            BunifuImageButton img = sender as BunifuImageButton;

            matc = img.Name.ToString();
            using (quanlithucungEntities1 quanli = new quanlithucungEntities1())
            {
                ThuCung thucung = quanli.ThuCungs.FirstOrDefault(p => p.MaThuCung == matc);
                cbLoaiThuCung.SelectedValue = thucung.MaLoai;
                txttenthucung.Text          = thucung.TenThuCung;
                txtdongia.Text = thucung.DonGia.ToString();
            }
        }
コード例 #2
0
 private void updateThuCung(string mathucung)
 {
     using (quanlithucungEntities1 quanli = new quanlithucungEntities1())
     {
         ThuCung      tc     = quanli.ThuCungs.FirstOrDefault(p => p.MaThuCung == mathucung);
         MemoryStream me     = new MemoryStream();
         byte[]       images = null;
         FileStream   stream = new FileStream(img, FileMode.Open, FileAccess.Read);
         BinaryReader brs    = new BinaryReader(stream);
         images = brs.ReadBytes((int)stream.Length);
         tc.Anh = images;
         quanli.SaveChanges();
         MessageBox.Show("Update thanh cong");
     }
 }
コード例 #3
0
        private void themSanPham()
        {
            if (cbDanhMuc.Text == "Thú Cưng")
            {
                string tenthucung = cbTen.Text;
                using (quanlithucungEntities1 quanli = new quanlithucungEntities1())
                {
                    ThuCung tc = quanli.ThuCungs.FirstOrDefault(p => p.TenThuCung.ToLower() == tenthucung.ToLower());

                    if (tc == null)
                    {
                        //Console.WriteLine("aaa");
                        quanli.insertCTPN(mapn, int.Parse(txtSoLuong.Text), double.Parse(txtGia.Text), tenthucung, cbLoai.SelectedValue.ToString(), null, txtdonvi.Text);
                        quanli.SaveChanges();
                        MessageBox.Show("Thêm thành công!");
                    }
                    else
                    {
                        tc.soluong += int.Parse(txtSoLuong.Text);
                        CTNhapThuCung tcm = new CTNhapThuCung();
                        tcm.MaPN       = mapn;
                        tcm.MaThuCung  = tc.MaThuCung;
                        tcm.TenThuCung = tc.TenThuCung;
                        tcm.MaLoai     = cbLoai.SelectedValue.ToString();
                        tcm.SoLuong    = int.Parse(txtSoLuong.Text);
                        tcm.GiaNhap    = double.Parse(txtGia.Text);
                        tcm.Donvi      = txtdonvi.Text;
                        quanli.CTNhapThuCungs.Add(tcm);
                        quanli.SaveChanges();
                        MessageBox.Show("Thêm thành công!");
                    }
                }
            }
            if (cbDanhMuc.Text == "Phụ Kiện")
            {
                themPhuKien();
            }
            if (cbDanhMuc.Text == "Thực Phẩm")
            {
                themThucPham();
            }
        }
コード例 #4
0
 private void loadThongTinTC(string mathucung)
 {
     using (quanlithucungEntities1 quanli = new quanlithucungEntities1())
     {
         ThuCung thuCung = quanli.ThuCungs.FirstOrDefault(p => p.MaThuCung == mathucung);
         cbDanhMuc.SelectedIndex = 0;
         cbLoai.SelectedValue    = thuCung.MaLoai;
         cbTen.SelectedValue     = thuCung.MaThuCung;
         txtdonvi.Text           = thuCung.Donvi;
         Byte[] img = thuCung.Anh;
         if (img != null)
         {
             using (MemoryStream stream = new MemoryStream(img))
             {
                 Image returnImage = Image.FromStream(stream);
                 hinhanh.Image = returnImage;
             }
         }
     }
 }
コード例 #5
0
        private void suaSanPham()
        {
            //string matc = cbTen.SelectedValue.ToString();
            using (quanlithucungEntities1 quanli = new quanlithucungEntities1())
            {
                CTNhapThuCung nhap = quanli.CTNhapThuCungs.FirstOrDefault(p => p.MaThuCung == matc && p.MaPN == mapn);
                //nhap.MaPN = "PN01";
                Console.WriteLine(nhap.MaThuCung);
                nhap.MaLoai     = cbLoai.SelectedValue.ToString();
                nhap.TenThuCung = cbTen.Text;
                nhap.SoLuong    = int.Parse(txtSoLuong.Text);
                nhap.GiaNhap    = double.Parse(txtGia.Text);
                nhap.Donvi      = txtdonvi.Text;
                quanli.SaveChanges();


                ThuCung tc = quanli.ThuCungs.FirstOrDefault(p => p.MaThuCung == matc);

                tc.TenThuCung = cbTen.Text;
                tc.MaLoai     = cbLoai.SelectedValue.ToString();
                tc.soluong   += int.Parse(txtSoLuong.Text);
                tc.DonGia     = double.Parse(txtGia.Text) + 0.1 * double.Parse(txtGia.Text);
                tc.Donvi      = txtdonvi.Text;
                if (dem == 1)
                {
                    MemoryStream me     = new MemoryStream();
                    byte[]       images = null;
                    FileStream   stream = new FileStream(img, FileMode.Open, FileAccess.Read);
                    BinaryReader brs    = new BinaryReader(stream);
                    images = brs.ReadBytes((int)stream.Length);
                    tc.Anh = images;
                }

                quanli.SaveChanges();
            }
        }