Exemplo n.º 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (kiemTraFeild())
            {
                string  tenVl   = txbTenVatLieu.Text;
                string  donVi   = txbDonViTinh.Text;
                decimal giaNhap = decimal.Parse(txbGiaNhap.Text);
                decimal giaBan  = decimal.Parse(txbGiaBan.Text);
                string  ghiChu  = txbGhiChu.Text;
                int     soLuong = Convert.ToInt32(txbSoLuong.Text);
                string  fileAnh = "";
                if (open.FileName == null)
                {
                    fileAnh = "";
                }
                else
                {
                    fileAnh = open.FileName;
                }


                VatLieu vl = new VatLieu(tenVl, donVi, giaNhap, giaBan, fileAnh, ghiChu, soLuong);

                if (VatLieuDAO.Instance.themVatLieu(vl) != 0)
                {
                    loadDataGrid();
                    MessageBox.Show("Thêm thành công");
                }
                else
                {
                    MessageBox.Show("Thêm thất bại");
                }
            }
        }
Exemplo n.º 2
0
 public ActionResult Chinhsua(VatLieu vl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vl).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         ViewBag.Dachinhsua = "Đã chỉnh sửa thành công";
     }
     return(View());
 }
Exemplo n.º 3
0
        public ActionResult Xoa(string MaVL)
        {
            VatLieu vatlieu = db.VatLieux.SingleOrDefault(n => n.MaVL == MaVL);

            if (vatlieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(vatlieu));
        }
Exemplo n.º 4
0
        public ActionResult XacnhanXoa(string MaVL)
        {
            VatLieu vatlieu = db.VatLieux.SingleOrDefault(n => n.MaVL == MaVL);

            if (vatlieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.VatLieux.Remove(vatlieu);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public VatLieu findvatlieu(ArrayList arrayList, string keyword)
        {
            VatLieu kq = null;

            foreach (VatLieu vatlieu in arrayList)
            {
                if (vatlieu.Tenvatlieu.Equals(keyword))
                {
                    kq = vatlieu;
                }
            }
            return(kq);
        }
Exemplo n.º 6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            VatLieu vl = new VatLieu(Convert.ToInt32(txbMaVatLieu.Text));

            if (VatLieuDAO.Instance.xoaVatLieu(vl) != 0)
            {
                loadDataGrid();
                MessageBox.Show("Xóa thành công");
            }
            else
            {
                MessageBox.Show("Xóa thất bại");
            }
        }
Exemplo n.º 7
0
        public void Sua(ArrayList arrayList)
        {
            Console.Write("                                Nhập tên vật liệu cần sửa: ");
            string  keyword = Console.ReadLine();
            VatLieu vatlieu = findvatlieu(arrayList, keyword);

            Console.Write("                                Nhập tên vật liệu : ");
            vatlieu.Tenvatlieu = Console.ReadLine();
            Console.Write("                                Nhập loại vật liệu: ");
            vatlieu.Loaivatlieu = Console.ReadLine();
            Console.WriteLine("                                NHập xuất xứ: ");
            vatlieu.Xuatxu = Console.ReadLine();
            Console.WriteLine("                                Nhập số lượng: ");
            vatlieu.Soluong = int.Parse(Console.ReadLine());
            Console.WriteLine("                                Nhập giá bán: ");
            vatlieu.Giaban = double.Parse(Console.ReadLine());
        }
Exemplo n.º 8
0
 public ActionResult ThemMoi(VatLieu vatlieu)
 {
     if (ModelState.IsValid)
     {
         VatLieu countvl = db.VatLieux.SingleOrDefault(n => n.MaVL == vatlieu.MaVL);
         if (countvl != null)
         {
             ViewBag.KiemtraMa = "Mã Vật liệu đã có hãy nhập lại hoặc đi đến chỉnh sửa";
         }
         else
         {
             db.VatLieux.Add(vatlieu);
             db.SaveChanges();
             ViewBag.Thanhcong = "Đã thêm thành công vật liệu.";
         }
     }
     return(View());
 }
        public ActionResult ThemChiTietHD(ChiTietHoaDonNhap cthd)
        {
            ViewBag.MaVL = new SelectList(db.VatLieux.ToList(), "MaVL", "TenVL");
            var x = db.HoaDonNhaps.ToList();

            cthd.MaHD = x.Last().MaHD;
            if (ModelState.IsValid)
            {
                db.ChiTietHoaDonNhaps.Add(cthd);
                db.SaveChanges();
                VatLieu vl = db.VatLieux.SingleOrDefault(n => n.MaVL == cthd.MaVL);
                vl.SoLuongTon      = vl.SoLuongTon + cthd.SoLuong;
                db.Entry(vl).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                ViewBag.Thanhcong = "Thêm thành công hóa đơn";
            }
            return(View());
        }
Exemplo n.º 10
0
        private void BtnVatLieu_Click(object sender, EventArgs e)
        {
            // kiểm tra quyền truy cập
            if (!biencucbo.loaitaikhoan.Equals("Quản Lý Kho") && !biencucbo.loaitaikhoan.Equals("admin"))
            {
                MessageBox.Show("Bạn không có quyền truy cập mục này");
                return;
            }
            un_btHeader_Click();
            pnContent.Controls.Clear();
            VatLieu vatLieu = new VatLieu();

            vatLieu.TopLevel = false;
            pnContent.Controls.Add(vatLieu);
            vatLieu.Show();
            this.btnVatLieu.BackColor             = Color.FromArgb(255, 127, 80);
            iconVatLieu.BackColor                 = Color.FromArgb(255, 127, 80);
            btnVatLieu.FlatAppearance.BorderColor = Color.White;
        }
        public ActionResult XacnhanXoa(string MaHD, string MaVL)
        {
            ChiTietHoaDonNhap ctpn    = db.ChiTietHoaDonNhaps.SingleOrDefault(n => n.MaHD == MaHD && n.MaVL == MaVL);
            HoaDonNhap        hd      = db.HoaDonNhaps.SingleOrDefault(n => n.MaHD == MaHD);
            VatLieu           vatlieu = db.VatLieux.SingleOrDefault(n => n.MaVL == ctpn.MaVL);

            if (ctpn != null)
            {
                db.ChiTietHoaDonNhaps.Remove(ctpn);
                //db.SaveChanges();
                vatlieu.SoLuongTon      = vatlieu.SoLuongTon - ctpn.SoLuong;
                db.Entry(vatlieu).State = System.Data.Entity.EntityState.Modified;
                // db.SaveChanges();
                db.HoaDonNhaps.Remove(hd);
                db.SaveChanges();
                ViewBag.Thanhcong = "Xóa Thành Công Hóa đơn";
            }
            return(View());
        }
Exemplo n.º 12
0
        public List <VatLieu> GetVatLieu()
        {
            const string        proc = "XemVatLieu";
            List <SqlParameter> para = new List <SqlParameter>()
            {
            };
            IDataReader    reader = DataProvider.ExecuteReader(proc, para);
            List <VatLieu> result = new List <VatLieu>();
            VatLieu        tk;

            while (reader.Read())
            {
                tk = new VatLieu();
                tk.AvailableAmount = Convert.ToInt32(reader["AvailableAmount"]);
                tk.MaterialID      = Convert.ToInt32(reader["MaterialID"]);
                tk.MaterialName    = Convert.ToString(reader["MaterialName"]);
                tk.ProviderName    = Convert.ToString(reader["ProviderName"]);
                tk.PhoneNumder     = Convert.ToString(reader["PhoneNumder"]);
                result.Add(tk);
            }
            return(result);
        }
Exemplo n.º 13
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (kiemTraFeild())
            {
                int     maVl    = Convert.ToInt32(txbMaVatLieu.Text);
                string  tenVl   = txbTenVatLieu.Text;
                string  donVi   = txbDonViTinh.Text;
                decimal giaNhap = decimal.Parse(txbGiaNhap.Text);
                decimal giaBan  = decimal.Parse(txbGiaBan.Text);
                string  ghiChu  = txbGhiChu.Text;
                int     soLuong = Convert.ToInt32(txbSoLuong.Text);
                string  fileAnh = open.FileName;

                /* MessageBox.Show(open.FileName);
                 * if (open.FileName == null || open.FileName == "")
                 * {
                 *   fileAnh = "";
                 * }
                 * else
                 * {
                 *   fileAnh = open.FileName;
                 * }*/

                VatLieu vl = new VatLieu(maVl, tenVl, donVi, giaNhap, giaBan, fileAnh, ghiChu, soLuong);

                if (VatLieuDAO.Instance.suaVatLieu(vl) != 0)
                {
                    loadDataGrid();
                    MessageBox.Show("Sửa thành công");
                }
                else
                {
                    MessageBox.Show("Sửa thất bại");
                }
            }
        }
Exemplo n.º 14
0
 public void display(VatLieu vatlieu)
 {
     Console.WriteLine("                                |{0,-20}|{1,-20}|{2,-20}|{3,-30}|{4,-40}|", vatlieu.Tenvatlieu, vatlieu.Loaivatlieu, vatlieu.Xuatxu, vatlieu.Soluong, vatlieu.Giaban);
 }