示例#1
0
        public static List <MayTinh> SearchMayTinh(string key, string x)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "SELECT * FROM dbo.May WHERE " + key + " LIKE N'%" + x + "%'";
            cmd.Connection  = conn;

            OpenConnection();
            SqlDataReader  reader = cmd.ExecuteReader();
            List <MayTinh> dsMT   = new List <MayTinh>();

            while (reader.Read())            // điều kiện đọc
            {
                string   mamay     = reader.GetString(0);
                string   tenmay    = reader.GetString(1);
                string   ram       = reader.GetString(2);
                string   hdd       = reader.GetString(3);
                string   tinhtrang = reader.GetString(4);
                DateTime hbh       = reader.GetDateTime(5);
                int      solanbh   = reader.GetInt32(6);
                string   mapm      = reader.GetString(7);

                MayTinh mt = new MayTinh(mamay, tenmay, ram, hdd, tinhtrang, hbh, solanbh, mapm);

                dsMT.Add(mt);
            }
            reader.Close();
            return(dsMT);
        }
示例#2
0
        public void Insert(MayTinh mt)
        {
            StreamWriter sw = File.AppendText(txtfile);

            sw.WriteLine(mt.maMT + "\t" + mt.tenMT + "\t" + mt.maNCC + "\t" + mt.sLCon + "\t" + mt.giaBan);
            sw.Close();
        }
示例#3
0
        public List <MayTinh> TimMayTinh(MayTinh mt)
        {
            List <MayTinh> list = mtDAL.GetData();
            List <MayTinh> kq   = new List <MayTinh>();

            if (mt.maMT == null && mt.tenMT == null)
            {
                kq = list;
            }
            if (mt.tenMT != null && mt.maMT == null)
            {
                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i].tenMT.IndexOf(mt.tenMT) >= 0)
                    {
                        kq.Add(new MayTinh(list[i]));
                    }
                }
            }
            else if (mt.tenMT == null && mt.maMT != null)
            {
                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i].maMT == mt.maMT)
                    {
                        kq.Add(new MayTinh(list[i]));
                    }
                }
            }
            else
            {
                kq = null;
            }
            return(kq);
        }
示例#4
0
        private void btnDeleteMT_Click(object sender, EventArgs e)
        {
            idx = 3;
            for (int i = 0; i < lvMayTinh.Items.Count; i++)
            {
                if (lvMayTinh.Items[i].Selected)
                {
                    if (lvMayTinh.SelectedIndices.Count == 0)
                    {
                        return;
                    }
                    MayTinh      mt  = new MayTinh();
                    ListViewItem liv = lvMayTinh.SelectedItems[0];
                    mt.MaMay  = liv.SubItems[0].Text;
                    mt.TenMay = liv.SubItems[1].Text;
                    mt.RAM    = liv.SubItems[2].Text;
                    mt.HDD    = liv.SubItems[3].Text;

                    mt.TinhTrang = liv.SubItems[4].Text;
                    string[] date = liv.SubItems[5].Text.Split('-');
                    DateTime dt   = new DateTime(int.Parse(date[2]), int.Parse(date[1]), int.Parse(date[0]));

                    mt.HanBH   = dt;
                    mt.SolanBH = Convert.ToInt32(liv.SubItems[6].Text);
                    mt.MaPM    = liv.SubItems[7].Text;

                    lstXoa.Add(mt);
                    lvMayTinh.Items[i].Remove();
                    i--;
                }
            }
        }
示例#5
0
        public static List <MayTinh> ShowMayTinh()
        {
            OpenConnection();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "LoadMay";
            cmd.Connection  = conn;

            SqlDataReader  reader = cmd.ExecuteReader();
            List <MayTinh> dsMT   = new List <MayTinh>();

            while (reader.Read())            // điều kiện đọc
            {
                string   mamay     = reader.GetString(0);
                string   tenmay    = reader.GetString(1);
                string   RAM       = reader.GetString(2);
                string   HDD       = reader.GetString(3);
                string   tinhtrang = reader.GetString(4);
                DateTime hbh       = reader.GetDateTime(5);
                int      solanbh   = reader.GetInt32(6);
                string   mapm      = reader.GetString(7);

                MayTinh mt = new MayTinh(mamay, tenmay, RAM, HDD, tinhtrang, hbh, solanbh, mapm);

                dsMT.Add(mt);
            }
            reader.Close();
            return(dsMT);
        }
示例#6
0
 public static void UpdateMayTinh(this MayTinh maytinh, MayTinhViewModel maytinhVM)
 {
     maytinh.ID          = maytinhVM.ID;
     maytinh.Name        = maytinhVM.Name;
     maytinh.CategoryPC  = maytinhVM.CategoryPC;
     maytinh.CreatedBy   = maytinhVM.CreatedBy;
     maytinh.Desciption  = maytinhVM.Desciption;
     maytinh.Status      = maytinhVM.Status;
     maytinh.CreatedDate = DateTime.Now;
 }
示例#7
0
 public void SuaMayTinh(MayTinh mt)
 {
     if (KT_MaMayTinh(mt.maMT) == true)
     {
         mtDAL.Update(mt);
     }
     else
     {
         throw new Exception("Không tồn tại mã này.");
     }
 }
示例#8
0
        public void CongSoLuong(MayTinh mt, int sl)
        {
            MayTinhDAL mt_DAL = new MayTinhDAL();

            if (KT_MaMayTinh(mt.maMT) == true)
            {
                mt_DAL.Update_Add(mt, sl);
            }
            else
            {
                throw new Exception("Không tồn tại mã này.");
            }
        }
示例#9
0
 public void ThemMayTinh(MayTinh mt)
 {
     if (mt.maMT != "" && mt.tenMT != "" && mt.maNCC != "")
     {
         mt.maMT  = CongCu.ChuanHoaMa(mt.maMT);
         mt.tenMT = CongCu.ChuanHoaXau(mt.tenMT);
         mt.maNCC = CongCu.ChuanHoaMa(mt.maNCC);
         mtDAL.Insert(mt);
     }
     else
     {
         throw new Exception("Dữ liệu sai.");
     }
 }
示例#10
0
        public MayTinh GETMAYTINH()
        {
            string   ma     = txtmamay.Text;
            string   ten    = txttenmay.Text;
            string   ram    = txtRAM.Text;
            string   hdd    = txtHDD.Text;
            string   ttrang = txttinhtrangmay.Text;
            DateTime hbh    = dtpNgayBHmay.Value;
            int      slbh   = int.Parse(txtsolanbhmay.Text);
            string   mapm   = cbmapm.Text;
            MayTinh  mt     = new MayTinh(ma, ten, ram, hdd, ttrang, hbh, slbh, mapm);

            return(mt);
        }
示例#11
0
        public MayTinh LayMayTinh(string mamt)
        {
            MayTinh mt = null;

            foreach (MayTinh maytinh in mtDAL.GetData())
            {
                if (maytinh.maMT == mamt)
                {
                    mt = new MayTinh(maytinh);
                    break;
                }
            }
            return(mt);
        }
示例#12
0
        public void Update(MayTinh mt)
        {
            List <MayTinh> list = GetData();

            for (int i = 0; i < list.Count; ++i)
            {
                if (list[i].maMT == mt.maMT)
                {
                    list[i] = mt;
                    break;
                }
            }
            StreamWriter sw = File.CreateText(txtfile);

            for (int i = 0; i < list.Count; ++i)
            {
                sw.WriteLine(list[i].maMT + "\t" + list[i].tenMT + "\t" + list[i].maNCC + "\t" + list[i].sLCon + "\t" + list[i].giaBan);
            }
            sw.Close();
        }
示例#13
0
        public static void UpDate(MayTinh mt)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "SuaMT";
            cmd.Connection  = conn;

            OpenConnection();
            cmd.Parameters.Add("@MaMay", SqlDbType.NVarChar).Value     = mt.MaMay;
            cmd.Parameters.Add("@TenMay", SqlDbType.NVarChar).Value    = mt.TenMay;
            cmd.Parameters.Add("@Ram", SqlDbType.NVarChar).Value       = mt.RAM;
            cmd.Parameters.Add("@HDD", SqlDbType.NVarChar).Value       = mt.HDD;
            cmd.Parameters.Add("@TinhTrang", SqlDbType.NVarChar).Value = mt.TinhTrang;
            cmd.Parameters.Add("@HanBH", SqlDbType.Date).Value         = mt.HanBH;
            cmd.Parameters.Add("@SolanBH", SqlDbType.Int).Value        = mt.SolanBH;
            cmd.Parameters.Add("@MaPM", SqlDbType.NVarChar).Value      = mt.MaPM;
            cmd.ExecuteNonQuery();
            CloseConnection();
        }
示例#14
0
 public HttpResponseMessage Update(HttpRequestMessage request, MayTinhViewModel maytinhViewModel)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             MayTinh maytinh = new MayTinh();
             maytinh.UpdateMayTinh(maytinhViewModel);
             _maytinhService.Update(maytinh);
             _maytinhService.SaveChange();
             var mapper = Mapper.Map <MayTinh, MayTinhViewModel>(maytinh);
             response = request.CreateResponse(HttpStatusCode.Created, mapper);
         }
         return response;
     }));
 }
        public HttpResponseMessage CreateMutile(HttpRequestMessage request, ChiTietSuaChuaViewModel chitietSuaChuaViewModel)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;


                MayTinh maytinh = new MayTinh()
                {
                    Name = chitietSuaChuaViewModel.MayTinh.Name,
                    CategoryPC = chitietSuaChuaViewModel.MayTinh.CategoryPC,
                    Desciption = chitietSuaChuaViewModel.MayTinh.Desciption,
                    Status = chitietSuaChuaViewModel.MayTinh.Status,
                };
                var createdMayTinh = _maytinhService.Create(maytinh);
                _maytinhService.SaveChange();

                KhachHang khachhang = new KhachHang()
                {
                    Name = chitietSuaChuaViewModel.KhachHang.Name,
                    Address = chitietSuaChuaViewModel.KhachHang.Address,
                    PhoneNumber = chitietSuaChuaViewModel.KhachHang.PhoneNumber
                };
                var createdKhachHang = _khachhangService.Create(khachhang);
                _khachhangService.SaveChange();

                ChiTietSuaChua chitietsuachua = new ChiTietSuaChua();
                chitietSuaChuaViewModel.IDMayTinh = createdMayTinh.ID;
                chitietSuaChuaViewModel.IDKhachHang = createdKhachHang.ID;
                chitietsuachua.UpdateChiTietSuaChua(chitietSuaChuaViewModel);

                var created = _chitietSuaChuaService.Create(chitietsuachua);
                var mapper = Mapper.Map <ChiTietSuaChua, ChiTietSuaChuaViewModel>(created);
                _chitietSuaChuaService.SaveChange();

                response = request.CreateResponse(HttpStatusCode.Created, mapper);
                return response;
            }));
        }
        public ActionResult Calculate(MayTinh model)
        {
            switch (model.O)
            {
            case '+':
                model.C = model.A + model.B;
                break;

            case '-':
                model.C = model.A - model.B;
                break;

            case 'x':
                model.C = model.A * model.B;
                break;

            case ':':
                model.C = model.A / model.B;
                break;
            }
            ViewBag.ThongTin = model;

            return(View("Index"));
        }
示例#17
0
        public void Nhap(int x, int y, ConsoleColor background_color, ConsoleColor text_color)
        {
            do
            {
                Console.BackgroundColor = background_color;
                Console.ForegroundColor = text_color;
                IMayTinhBLL maytinh  = new MayTinhBLL();
                HDNhapBLL   hdnBLL   = new HDNhapBLL();
                MayTinhBLL  mtBLL    = new MayTinhBLL();
                FormHDNhap  fcthdn   = new FormHDNhap();
                CTHDNhapBLL cthdnBLL = new CTHDNhapBLL();
                MayTinh     mt       = new MayTinh();

                Console.Clear();
                IO.Box(0, 0, 28, 114, ConsoleColor.Black, ConsoleColor.White);
                IO.BoxTitle("                                          THÊM GIÁ BÁN MÁY TÍNH", x, y, 10, 110);
                IO.Writexy("Mã MT:", x + 2, y + 3);
                IO.Writexy("Tên máy:", x + 43, y + 3);
                IO.Writexy("Mã nhà CC:", x + 2, y + 5);
                IO.Writexy("Số lượng còn:", x + 37, y + 5);
                IO.Writexy("Giá bán:", x + 74, y + 5);
                IO.Writexy("------------------------------------------------------------------------------------------------------------", x + 1, y + 6);
                IO.Writexy("Nhập ! để thoát...", x + 4, y + 8);

                fcthdn.HienCT_N(x - 1, y + 10, cthdnBLL.LayDS_CTHDNhap(), 5, 0);
                do
                {
                    Console.SetCursorPosition(x + 9, y + 3);
                    mt.maMT = Console.ReadLine();
                    if (mt.maMT == null)
                    {
                        IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã máy tính...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else if (mt.maMT == "!")
                    {
                        return;
                    }
                    else
                    {
                        if (cthdnBLL.KT_MaMT(CongCu.ChuanHoaMa(mt.maMT)) == false)
                        {
                            IO.Writexy("Không tồn tại mã máy tính này...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 8, y + 3, 10, ConsoleColor.Black);
                        }
                        else if (mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(mt.maMT)) == true)
                        {
                            IO.Writexy("Mã máy tính này đã tồn tại...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 8, y + 3, 10, ConsoleColor.Black);
                        }
                        else
                        {
                            mt.maMT = CongCu.ChuanHoaMa(mt.maMT);
                        }
                    }
                } while (mt.maMT == null || cthdnBLL.KT_MaMT(CongCu.ChuanHoaMa(mt.maMT)) == false || mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(mt.maMT)) == true);
                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);

                CTHDNhap ctn = cthdnBLL.LayMT(CongCu.ChuanHoaMa(mt.maMT));
                IO.Writexy(ctn.tenMT, x + 52, y + 3);
                mt.tenMT = ctn.tenMT;

                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                mt.maNCC = hdnBLL.LayMaNCC(CongCu.ChuanHoaMa(mt.maMT));
                IO.Writexy(mt.maNCC, x + 13, y + 5);

                IO.Writexy(ctn.soLuong.ToString(), x + 51, y + 5);
                mt.sLCon = ctn.soLuong;

                fcthdn.HienCT_N(x - 1, y + 10, cthdnBLL.LayDS_CTHDNhap(), 5, 0);
                IO.Clear(x + 13, y + 7, 60, ConsoleColor.Black);
                do
                {
                    mt.giaBan = double.Parse(IO.ReadNumber(x + 83, y + 5));
                    if (mt.giaBan <= 0)
                    {
                        IO.Writexy("Nhập lại giá bán...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                        IO.Clear(x + 82, y + 5, 20, ConsoleColor.Black);
                    }
                    else if (mt.giaBan <= ctn.donGia)
                    {
                        IO.Writexy("Nhập lại giá bán lớn hơn giá nhập...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                        IO.Clear(x + 82, y + 5, 20, ConsoleColor.Black);
                    }
                } while (mt.giaBan < 0 || mt.giaBan <= ctn.donGia);

                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát...", x + 4, y + 7);
                Console.SetCursorPosition(x + 34, y + 7);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    IO.Writexy("Giá bán đã được thêm...", x + 4, y + 7);
                    maytinh.ThemMayTinh(mt);
                    Hien(x + 9, y + 10, maytinh.LayDSMayTinh(), 5, 1);
                }
            } while (true);
        }
示例#18
0
        public void Sua(int x, int y, ConsoleColor background_color, ConsoleColor text_color)
        {
            do
            {
                Console.BackgroundColor = background_color;
                Console.ForegroundColor = text_color;
                IMayTinhBLL maytinh = new MayTinhBLL();
                INCC_BLL    nhacc   = new NCC_BLL();
                FormNCC     fncc    = new FormNCC();
                NCC_BLL     nccBLL  = new NCC_BLL();
                MayTinhBLL  mtBLL   = new MayTinhBLL();

                Console.Clear();
                IO.Box(0, 0, 28, 114, ConsoleColor.Black, ConsoleColor.White);
                IO.BoxTitle("                                       CẬP NHẬT THÔNG TIN MÁY TÍNH", x, y, 10, 110);
                IO.Writexy("Mã MT:", x + 2, y + 3);
                IO.Writexy("Tên máy:", x + 43, y + 3);
                IO.Writexy("Mã nhà CC:", x + 2, y + 5);
                IO.Writexy("Số lượng còn:", x + 37, y + 5);
                IO.Writexy("Giá bán:", x + 74, y + 5);
                IO.Writexy("------------------------------------------------------------------------------------------------------------", x + 1, y + 6);
                IO.Writexy("Nhập ! để thoát...", x + 4, y + 8);
                Hien(x + 9, y + 10, maytinh.LayDSMayTinh(), 5, 0);

                string mamt;
                string tenmay;
                string mancc;
                int    slc;
                double giaban;

                do
                {
                    Console.SetCursorPosition(x + 9, y + 3);
                    mamt = Console.ReadLine();
                    if (mamt == "")
                    {
                        IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã máy tính...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else if (mamt == "!")
                    {
                        return;
                    }
                    else
                    {
                        if (mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(mamt)) == false)
                        {
                            IO.Writexy("Không tồn tại mã máy tính này...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 8, y + 3, 34, ConsoleColor.Black);
                        }
                        else
                        {
                            mamt = CongCu.ChuanHoaMa(mamt);
                        }
                    }
                } while (mamt == "" || mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(mamt)) == false);
                MayTinh mt = maytinh.LayMayTinh(mamt);

                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                do
                {
                    Console.SetCursorPosition(x + 52, y + 3);
                    tenmay = Console.ReadLine();
                    if (tenmay == "")
                    {
                        IO.Writexy("Nhập lại tên máy tính...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else if (tenmay != mt.tenMT && tenmay != "")
                    {
                        mt.tenMT = CongCu.ChuanHoaXau(tenmay);
                    }
                } while (tenmay == "");
                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                fncc.Hien(x + 16, y + 10, nhacc.LayDSNCC(), 5, 0);
                do
                {
                    Console.SetCursorPosition(x + 13, y + 5);
                    mancc = Console.ReadLine();
                    if (mancc == "")
                    {
                        IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã nhà cung cấp...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else
                    {
                        if (nccBLL.KT_MaNCC(CongCu.ChuanHoaMa(mancc)) == false)
                        {
                            IO.Writexy("Không tồn tại mã nhà cung cấp này...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 12, y + 5, 24, ConsoleColor.Black);
                        }
                        else if (mancc != mt.maNCC && mancc != "")
                        {
                            mt.maNCC = CongCu.ChuanHoaMa(mancc);
                        }
                    }
                } while (mancc == "" || nccBLL.KT_MaNCC(CongCu.ChuanHoaMa(mancc)) == false);
                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                Hien(x + 9, y + 10, maytinh.LayDSMayTinh(), 5, 0);
                do
                {
                    slc = int.Parse(IO.ReadNumber(x + 51, y + 5));
                    if (slc < 0)
                    {
                        IO.Writexy("Nhập lại số lượng còn...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                        IO.Clear(x + 50, y + 5, 16, ConsoleColor.Black);
                    }
                    else if (slc != mt.sLCon && slc >= 0)
                    {
                        mt.sLCon = slc;
                    }
                } while (slc < 0);
                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                do
                {
                    giaban = double.Parse(IO.ReadNumber(x + 83, y + 5));
                    if (giaban <= 0)
                    {
                        IO.Writexy("Nhập lại giá bán...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                        IO.Clear(x + 82, y + 5, 20, ConsoleColor.Black);
                    }
                    else if (giaban != mt.giaBan && giaban > 0)
                    {
                        mt.giaBan = giaban;
                    }
                } while (giaban <= 0);

                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                IO.Writexy("Enter để cập nhật, Esc để thoát...", x + 4, y + 7);
                Console.SetCursorPosition(x + 38, y + 7);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    IO.Writexy("Máy tính đã được cập nhật...", x + 4, y + 7);
                    maytinh.SuaMayTinh(mt);
                    Hien(x + 9, y + 10, maytinh.LayDSMayTinh(), 5, 1);
                }
            } while (true);
        }
示例#19
0
 public MayTinh Create(MayTinh maytinh)
 {
     return(_maytinhRepository.Add(maytinh));
 }
示例#20
0
        private void button1_Click(object sender, EventArgs e)
        {
            MayTinh bai_1 = new MayTinh();

            bai_1.ShowDialog();
        }
示例#21
0
 public static void SuaNV(MayTinh mt)
 {
     MayTinhAccess.UpDate(mt);
 }
示例#22
0
 public static void ThemNV(MayTinh mt)
 {
     MayTinhAccess.Insert(mt);
 }
示例#23
0
 public void Update(MayTinh maytinh)
 {
     _maytinhRepository.Update(maytinh);
 }
示例#24
0
        public void Nhap(int x, int y, ConsoleColor background_color, ConsoleColor text_color)
        {
            do
            {
                Console.BackgroundColor = background_color;
                Console.ForegroundColor = text_color;
                IHDBanBLL     hdban     = new HDBanBLL();
                INhanVienBLL  nhanvien  = new NhanVienBLL();
                IKhachHangBLL khachhang = new KhachHangBLL();
                IMayTinhBLL   maytinh   = new MayTinhBLL();
                IHDNhapBLL    hdnhap    = new HDNhapBLL();
                FormNhanVien  fnv       = new FormNhanVien();
                FormKhachHang fkh       = new FormKhachHang();
                FormMayTinh   fmt       = new FormMayTinh();
                NhanVienBLL   nvBLL     = new NhanVienBLL();
                KhachHangBLL  khBLL     = new KhachHangBLL();
                MayTinhBLL    mtBLL     = new MayTinhBLL();
                FormHDNhap    fhdn      = new FormHDNhap();
                ICTHDBanBLL   cthdban   = new CTHDBanBLL();
                HDBanBLL      hdbBLL    = new HDBanBLL();
                HDBan         hdb       = new HDBan();
                CTHDBan       cthdb     = new CTHDBan();
                HDBan         hd;


                Console.Clear();
                IO.Box(0, 0, 28, 114, ConsoleColor.Black, ConsoleColor.White);
                IO.BoxTitle("                                         NHẬP THÔNG TIN HÓA ĐƠN BÁN", x, y, 10, 112);
                IO.Writexy("Mã nhân viên:", x + 2, y + 3);
                IO.Writexy("Mã khách hàng:", x + 28, y + 3);
                IO.Writexy("Ngày bán:", x + 55, y + 3);
                IO.Writexy("Tổng tiền:", x + 83, y + 3);
                IO.Writexy("--------------------------------------------------------------------------------------------------------------", x + 1, y + 4);
                IO.Writexy("Mã máy tính:", x + 2, y + 5);
                IO.Writexy("Số lượng:", x + 28, y + 5);
                IO.Writexy("Đơn giá:", x + 55, y + 5);
                IO.Writexy("Thành tiền:", x + 83, y + 5);
                IO.Writexy("--------------------------------------------------------------------------------------------------------------", x + 1, y + 6);
                IO.Writexy("Nhập ! để thoát...", x + 4, y + 8);

                fnv.Hien(x, y + 10, nhanvien.LayDSNhanVien(), 5, 0);
                do
                {
                    Console.SetCursorPosition(x + 16, y + 3);
                    hdb.maNV = Console.ReadLine();
                    if (hdb.maNV == null)
                    {
                        IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã nhân viên...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else if (hdb.maNV == "!")
                    {
                        return;
                    }
                    else
                    {
                        if (nvBLL.KT_MaNhanVien(CongCu.ChuanHoaMa(hdb.maNV)) == false)
                        {
                            IO.Writexy("Không tồn tại mã nhân viên này...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 15, y + 3, 12, ConsoleColor.Black);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hdb.maNV == null || nvBLL.KT_MaNhanVien(CongCu.ChuanHoaMa(hdb.maNV)) == false);
                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                fkh.Hien(x + 16, y + 10, khachhang.LayDSKhachHang(), 5, 0);
                do
                {
                    Console.SetCursorPosition(x + 43, y + 3);
                    hdb.maKH = Console.ReadLine();
                    if (hdb.maKH == null)
                    {
                        IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã khách hàng...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else
                    {
                        if (khBLL.KT_MaKhachHang(CongCu.ChuanHoaMa(hdb.maKH)) == false)
                        {
                            IO.Writexy("Không tồn tại mã khách hàng này...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 42, y + 3, 12, ConsoleColor.Black);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hdb.maKH == null || khBLL.KT_MaKhachHang(CongCu.ChuanHoaMa(hdb.maKH)) == false);
                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                fhdn.Hien(x + 13, y + 10, hdnhap.LayDSHDNhap(), 5, 0);
                IO.Writexy("Nhập ngày bán định dạng 'dd/MM/yyyy'...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                do
                {
                    Console.SetCursorPosition(x + 65, y + 3);
                    hdb.ngayBan = Console.ReadLine();
                    if (hdb.ngayBan == null || CongCu.CheckDate(hdb.ngayBan) == false)
                    {
                        IO.Writexy("Nhập lại ngày bán...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                        IO.Clear(x + 64, y + 3, 18, ConsoleColor.Black);
                    }
                } while (hdb.ngayBan == null || CongCu.CheckDate(hdb.ngayBan) == false);

                hdban.ThemHDBan(hdb);

                while (true)
                {
                    hd          = hdbBLL.LayMaHDB(hdb.maNV, hdb.maKH, hdb.ngayBan);
                    cthdb.maHDB = hd.maHDB;

                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    fmt.Hien(x + 11, y + 10, maytinh.LayDSMayTinh(), 5, 0);
                    do
                    {
                        IO.Clear(x + 14, y + 5, 13, ConsoleColor.Black);
                        Console.SetCursorPosition(x + 15, y + 5);
                        cthdb.maMT = Console.ReadLine();
                        if (cthdb.maMT == null)
                        {
                            IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                            IO.Writexy("Nhập lại mã máy tính...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                        }
                        else
                        {
                            if (mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(cthdb.maMT)) == false)
                            {
                                IO.Writexy("Không tồn tại mã máy tính này...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                                IO.Clear(x + 14, y + 5, 13, ConsoleColor.Black);
                            }
                            else
                            {
                                break;
                            }
                        }
                    } while (cthdb.maMT == null || mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(cthdb.maMT)) == false);
                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    MayTinh mt = mtBLL.LayMayTinh(CongCu.ChuanHoaMa(cthdb.maMT));
                    do
                    {
                        IO.Clear(x + 37, y + 5, 14, ConsoleColor.Black);
                        cthdb.soLuong = int.Parse(IO.ReadNumber(x + 38, y + 5));
                        if (cthdb.soLuong <= 0 || mt.sLCon <= 0 || cthdb.soLuong > mt.sLCon)
                        {
                            IO.Writexy("Nhập lại số lượng...", x + 4, y + 7, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 37, y + 5, 14, ConsoleColor.Black);
                        }
                    } while (cthdb.soLuong <= 0 || mt.sLCon <= 0 || cthdb.soLuong > mt.sLCon);

                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    IO.Clear(x + 63, y + 5, 16, ConsoleColor.Black);
                    cthdb.donGia = mt.giaBan;
                    IO.Writexy(cthdb.donGia.ToString(), x + 64, y + 5);


                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    IO.Clear(x + 94, y + 5, 16, ConsoleColor.Black);
                    IO.Writexy(cthdb.thanhTien.ToString(), x + 95, y + 5);

                    cthdban.ThemCTHDBan(cthdb);

                    if (mtBLL.KT_MaMayTinh(cthdb.maMT) == true)
                    {
                        mtBLL.TruSoLuong(mt, cthdb.soLuong);
                    }

                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    Console.SetCursorPosition(x + 34, y + 7);
                    IO.Writexy("Nhập tiếp? (C/K)...", x + 4, y + 7);
                    ConsoleKeyInfo c = Console.ReadKey();
                    if (c.KeyChar != 'c')
                    {
                        break;
                    }
                }

                IO.Clear(x + 93, y + 5, 16, ConsoleColor.Black);
                IO.Writexy(hdbBLL.TTien(cthdb.maHDB).ToString(), x + 94, y + 3);
                hdb.tongTien = hdbBLL.TTien(cthdb.maHDB);

                IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát...", x + 4, y + 7);
                Console.SetCursorPosition(x + 34, y + 7);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    IO.Clear(x + 3, y + 7, 60, ConsoleColor.Black);
                    IO.Writexy("Hóa đơn bán đã được thêm...", x + 4, y + 7);
                    hdban.XoaHDBan(cthdb.maHDB);
                    hdban.ThemHDBan(hdb);
                    Hien(x + 13, y + 10, hdban.LayDSHDBan(), 5, 1);
                }
            } while (true);
        }
示例#25
0
        public void Nhap(int x, int y, ConsoleColor background_color, ConsoleColor text_color)
        {
            do
            {
                Console.BackgroundColor = background_color;
                Console.ForegroundColor = text_color;
                IHDNhapBLL   hdnhap   = new HDNhapBLL();
                INhanVienBLL nhanvien = new NhanVienBLL();
                INCC_BLL     nhacc    = new NCC_BLL();
                IMayTinhBLL  maytinh  = new MayTinhBLL();
                FormNhanVien fnv      = new FormNhanVien();
                FormNCC      fncc     = new FormNCC();
                FormMayTinh  fmt      = new FormMayTinh();
                NhanVienBLL  nvBLL    = new NhanVienBLL();
                NCC_BLL      nccBLL   = new NCC_BLL();
                ICTHDNhapBLL cthdnhap = new CTHDNhapBLL();
                HDNhapBLL    hdnBLL   = new HDNhapBLL();
                MayTinhBLL   mtBLL    = new MayTinhBLL();
                HDNhap       hdn      = new HDNhap();
                CTHDNhap     cthdn    = new CTHDNhap();
                HDNhap       hd;

                Console.Clear();
                IO.Box(0, 0, 28, 114, ConsoleColor.Black, ConsoleColor.White);
                IO.BoxTitle("                                        NHẬP THÔNG TIN HÓA ĐƠN NHẬP", x, y, 11, 112);
                IO.Writexy("Mã nhân viên:", x + 2, y + 3);
                IO.Writexy("Mã nhà CC:", x + 28, y + 3);
                IO.Writexy("Ngày nhập:", x + 55, y + 3);
                IO.Writexy("Tổng tiền:", x + 83, y + 3);
                IO.Writexy("--------------------------------------------------------------------------------------------------------------", x + 1, y + 4);
                IO.Writexy("Mã máy tính:", x + 2, y + 5);
                IO.Writexy("Tên máy tính:", x + 2, y + 6);
                IO.Writexy("Số lượng:", x + 28, y + 5);
                IO.Writexy("Đơn giá:", x + 55, y + 5);
                IO.Writexy("Thành tiền:", x + 83, y + 5);
                IO.Writexy("--------------------------------------------------------------------------------------------------------------", x + 1, y + 7);
                IO.Writexy("Nhập ! để thoát...", x + 4, y + 9);

                fnv.Hien(x, y + 11, nhanvien.LayDSNhanVien(), 5, 0);
                do
                {
                    Console.SetCursorPosition(x + 16, y + 3);
                    hdn.maNV = Console.ReadLine();
                    if (hdn.maNV == null)
                    {
                        IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã nhân viên...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else if (hdn.maNV == "!")
                    {
                        return;
                    }
                    else
                    {
                        if (nvBLL.KT_MaNhanVien(CongCu.ChuanHoaMa(hdn.maNV)) == false)
                        {
                            IO.Writexy("Không tồn tại mã nhân viên này...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 15, y + 3, 12, ConsoleColor.Black);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hdn.maNV == null || nvBLL.KT_MaNhanVien(CongCu.ChuanHoaMa(hdn.maNV)) == false);
                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                IO.Clear(x + 3, y + 9, 60, ConsoleColor.Black);
                fncc.Hien(x + 16, y + 11, nhacc.LayDSNCC(), 5, 0);
                do
                {
                    Console.SetCursorPosition(x + 39, y + 3);
                    hdn.maNCC = Console.ReadLine();
                    if (hdn.maNCC == null)
                    {
                        IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập lại mã nhà cung cấp...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                    }
                    else
                    {
                        if (nccBLL.KT_MaNCC(CongCu.ChuanHoaMa(hdn.maNCC)) == false)
                        {
                            IO.Writexy("Không tồn tại mã nhà cung cấp này...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 38, y + 3, 16, ConsoleColor.Black);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hdn.maNCC == null || nccBLL.KT_MaNCC(CongCu.ChuanHoaMa(hdn.maNCC)) == false);
                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                IO.Writexy("Nhập ngày nhập định dạng 'dd/MM/yyyy'...", x + 4, y + 9, ConsoleColor.Black, ConsoleColor.White);
                do
                {
                    Console.SetCursorPosition(x + 66, y + 3);
                    hdn.ngayNhap = Console.ReadLine();
                    if (hdn.ngayNhap == null || CongCu.CheckDate(hdn.ngayNhap) == false)
                    {
                        IO.Writexy("Nhập lại ngày nhập...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                        IO.Clear(x + 65, y + 3, 17, ConsoleColor.Black);
                    }
                } while (hdn.ngayNhap == null || CongCu.CheckDate(hdn.ngayNhap) == false);

                hdnhap.ThemHDNhap(hdn);

                while (true)
                {
                    hd          = hdnBLL.LayMaHDN(hdn.maNV, hdn.maNCC, hdn.ngayNhap);
                    cthdn.maHDN = hd.maHDN;

                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    fmt.Hien(x + 11, y + 11, maytinh.LayDSMayTinh(), 5, 0);
                    do
                    {
                        IO.Clear(x + 14, y + 5, 12, ConsoleColor.Black);
                        Console.SetCursorPosition(x + 15, y + 5);
                        cthdn.maMT = Console.ReadLine();
                        if (cthdn.maMT == null)
                        {
                            IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                            IO.Writexy("Nhập lại mã máy tính...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                        }
                    } while (cthdn.maMT == null);
                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);

                    if (mtBLL.KT_MaMayTinh(CongCu.ChuanHoaMa(cthdn.maMT)) == true)
                    {
                        MayTinh Mt = mtBLL.LayMayTinh(CongCu.ChuanHoaMa(cthdn.maMT));
                        IO.Writexy(Mt.tenMT, x + 16, y + 6);
                        cthdn.tenMT = Mt.tenMT;
                    }
                    else
                    {
                        do
                        {
                            IO.Clear(x + 14, y + 6, 90, ConsoleColor.Black);
                            Console.SetCursorPosition(x + 16, y + 6);
                            cthdn.tenMT = Console.ReadLine();
                            if (cthdn.tenMT == null)
                            {
                                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                                IO.Writexy("Nhập lại tên máy tính...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                            }
                        } while (cthdn.tenMT == null);
                    }

                    IO.Clear(x + 3, y + 9, 60, ConsoleColor.Black);
                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    do
                    {
                        IO.Clear(x + 37, y + 5, 16, ConsoleColor.Black);
                        cthdn.soLuong = int.Parse(IO.ReadNumber(x + 38, y + 5));
                        if (cthdn.soLuong <= 0)
                        {
                            IO.Writexy("Nhập lại số lượng...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 37, y + 5, 16, ConsoleColor.Black);
                        }
                    } while (cthdn.soLuong <= 0);
                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    HienCT_N(x, y + 11, cthdnhap.LayDS_CTHDNhap(), 5, 0);
                    do
                    {
                        IO.Clear(x + 63, y + 5, 16, ConsoleColor.Black);
                        cthdn.donGia = double.Parse(IO.ReadNumber(x + 64, y + 5));
                        if (cthdn.donGia <= 0)
                        {
                            IO.Writexy("Nhập lại đơn giá...", x + 4, y + 8, ConsoleColor.Black, ConsoleColor.White);
                            IO.Clear(x + 63, y + 5, 16, ConsoleColor.Black);
                        }
                    } while (cthdn.donGia <= 0);

                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    IO.Clear(x + 94, y + 5, 16, ConsoleColor.Black);
                    IO.Writexy(cthdn.thanhTien.ToString(), x + 95, y + 5);

                    cthdnhap.ThemCTHDNhap(cthdn);

                    MayTinh mt = mtBLL.LayMayTinh(CongCu.ChuanHoaMa(cthdn.maMT));
                    if (mtBLL.KT_MaMayTinh(cthdn.maMT) == true)
                    {
                        mtBLL.CongSoLuong(mt, cthdn.soLuong);
                    }
                    else
                    {
                        cthdn.soLuong = cthdn.soLuong;
                    }

                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    Console.SetCursorPosition(x + 34, y + 8);
                    IO.Writexy("Nhập tiếp? (C/K)...", x + 4, y + 8);
                    ConsoleKeyInfo c = Console.ReadKey();
                    if (c.KeyChar != 'c')
                    {
                        break;
                    }
                }

                IO.Clear(x + 93, y + 5, 16, ConsoleColor.Black);
                IO.Writexy(hdnBLL.TTien(cthdn.maHDN).ToString(), x + 94, y + 3);
                hdn.tongTien = hdnBLL.TTien(cthdn.maHDN);

                IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát...", x + 4, y + 8);
                Console.SetCursorPosition(x + 34, y + 8);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    IO.Clear(x + 3, y + 8, 60, ConsoleColor.Black);
                    IO.Writexy("Hóa đơn nhập đã được thêm...", x + 4, y + 8);
                    hdnhap.XoaHDNhap(cthdn.maHDN);
                    hdnhap.ThemHDNhap(hdn);
                    Hien(x + 13, y + 11, hdnhap.LayDSHDNhap(), 5, 1);
                }
            } while (true);
        }