Beispiel #1
0
        public List <eMayTinh> getMayTinhThuocPhong(string maphonghoc)
        {
            var dsmaytinh = db.tblMaytinhs.Where
                                (x => x.msPhong == maphonghoc).ToList().OrderBy(x => x.CPU);


            var dsmaytinh1 = (from x in db.tblMaytinhs
                              where x.msPhong == maphonghoc
                              orderby x.CPU descending
                              select x).ToList();


            List <eMayTinh> ls = new List <eMayTinh>();

            foreach (tblMaytinh mttemp in dsmaytinh)
            {
                eMayTinh mt = new eMayTinh();
                mt.MaMay    = mttemp.msMay;
                mt.CPU      = mttemp.CPU;
                mt.HardDisk = mttemp.HardDisk;
                mt.RAM      = mttemp.RAM;
                mt.Monitor  = mttemp.Monitor;
                mt.VGA      = mttemp.VGA;
                mt.MsPhong  = mttemp.msPhong;
                ls.Add(mt);
            }
            return(ls);
        }
Beispiel #2
0
        eMayTinh TaoMoiMayTinh()
        {
            eMayTinh newmt = new eMayTinh();

            newmt.MaMay    = txtMsMay.Text.Trim();
            newmt.CPU      = txtCPU.Text;
            newmt.HardDisk = txtHard.Text;
            newmt.RAM      = txtRam.Text;
            newmt.VGA      = txtVGA.Text;
            newmt.Monitor  = txtMonitor.Text;
            newmt.MsPhong  = trePhong.SelectedNode.Tag.ToString();
            return(newmt);
        }
Beispiel #3
0
 private void lvwDSMay_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvwDSMay.SelectedItems.Count > 0)//co chon
     {
         eMayTinh mt = (eMayTinh)lvwDSMay.SelectedItems[0].Tag;
         txtMsMay.Text   = mt.MaMay;
         txtCPU.Text     = mt.CPU;
         txtHard.Text    = mt.HardDisk;
         txtRam.Text     = mt.RAM;
         txtVGA.Text     = mt.VGA;
         txtMonitor.Text = mt.Monitor;
     }
 }
Beispiel #4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            eMayTinh newmt = TaoMoiMayTinh();
            int      kq    = qlMTinh.insertMayTinh(newmt);

            if (kq == 1)
            {
                MessageBox.Show("Thêm thành công!!!");
            }
            else
            {
                MessageBox.Show("Lỗi trùng khóa, vui lòng kiểm tra lại!");
            }
            //đưa lại datagridview
            LoadDSVaoListView(lvwDSMay);
        }
Beispiel #5
0
        public int insertMayTinh(eMayTinh mtmoi)
        {
            // if (CheckIfExist(mtmoi.MaMay)==true)
            if (CheckIfExist(mtmoi.MaMay))
            {
                return(0);
            }

            tblMaytinh mttemp = new tblMaytinh();

            mttemp.msMay    = mtmoi.MaMay;
            mttemp.RAM      = mtmoi.RAM;
            mttemp.Monitor  = mtmoi.Monitor;
            mttemp.VGA      = mtmoi.VGA;
            mttemp.HardDisk = mtmoi.HardDisk;
            mttemp.CPU      = mtmoi.CPU;
            mttemp.msPhong  = mtmoi.MsPhong;

            db.tblMaytinhs.InsertOnSubmit(mttemp);
            db.SubmitChanges();
            return(1);
        }