Example #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     //1 ktra tính đúng của dữ liệu
     //2 lưu vào csdl khi đã đúng dl
     //2.1 tạo đối tượng obj
     //2.2 cập nhật obj vào CSDL
     //3 tái hiện lại cho user xem
     if (KiemTraDuLieu())
     {
         if (btnXoaTrang.Text.Equals("Huỷ thêm mới"))// tình trạng có thể thêm mới
         {
             lblMay newmt      = new lblMay();
             string strMaPhong = trePhong.SelectedNode.Tag.ToString();
             newmt.id       = txtMSMay.Text;
             newmt.cpu      = txtCPU.Text;
             newmt.hdd      = txtHardDisk.Text;
             newmt.ram      = txtRam.Text;
             newmt.vga      = txtVGA.Text;
             newmt.monitor  = txtMonitor.Text;
             newmt.id_Phong = strMaPhong;
             objMay.ThemMTMoi(newmt);
             //load to listview
             IEnumerable <lblMay> lstmayTinhThuocPhong = objMay.GetMayTinhThuocPhongHoc(strMaPhong);
             dgrMayTinh.DataSource = lstmayTinhThuocPhong;
             FormatDaTaGrid(dgrMayTinh);
         }
     }
     else
     {
         int a = 8;
     }
 }
Example #2
0
        public lblMay TimKhiBietMa(String strMaMay)
        {
            lblMay mt = (from n in dt.lblMays
                         where n.id.Equals(strMaMay)
                         select n).FirstOrDefault();

            return(mt);
        }
Example #3
0
 void LoadListViewToText(lblMay mt)//load dữ liệu từ listview xuống textbox
 {
     txtMSMay.Text    = mt.id;
     txtCPU.Text      = mt.cpu;
     txtHardDisk.Text = mt.hdd;
     txtRam.Text      = mt.ram;
     txtVGA.Text      = mt.vga;
     txtMonitor.Text  = mt.monitor;
 }
Example #4
0
 void objectToText(lblMay mt)
 {
     txtMSMay.Text    = mt.id;
     txtCPU.Text      = mt.cpu;
     txtHardDisk.Text = mt.hdd;
     txtRam.Text      = mt.ram;
     txtVGA.Text      = mt.vga;
     txtMonitor.Text  = mt.monitor;
 }
Example #5
0
 void LoadTreeViewToText(lblMay mt)//load dl từ treeview xuống textbox
 {
     txtMSMay.Text    = mt.id;
     txtCPU.Text      = mt.cpu;
     txtHardDisk.Text = mt.hdd;
     txtRam.Text      = mt.ram;
     txtVGA.Text      = mt.vga;
     txtMonitor.Text  = mt.monitor;
 }
Example #6
0
        private void lvwMayTinh_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblMay mt = null;

            if (dgrMayTinh.SelectedRows.Count > 0)
            {
                mt = (lblMay)dgrMayTinh.SelectedRows[0].Tag;
                objectToText(mt);
            }
        }
Example #7
0
 public bool ThemMayTinh(lblMay may)
 {
     try
     {
         dt.lblMays.InsertOnSubmit(may);
         dt.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Example #8
0
 public void ThemMTMoi(lblMay newMT)//hàm thêm máy tính mới
 {
     System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction();
     try
     {
         dt.Transaction = myTran;
         dt.lblMays.InsertOnSubmit(newMT);//đưa vào CSDL
         dt.SubmitChanges();
         dt.Transaction.Commit();
     }
     catch (Exception ex)
     {
         dt.Transaction.Rollback();
         // throw new Exception(ex.Message);
     }
 }
Example #9
0
        private void trePhong_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = trePhong.SelectedNode;

            if (node.Level == 0)
            {
                string idPhong            = node.Text.Split(':')[1].Trim();
                IEnumerable <lblMay> list = objMay.GetMayTinhThuocPhong(idPhong);
                LoadDataToListView(list);
            }
            else if (node.Level == 2)
            {
                lblMay mt = (lblMay)node.Tag;

                objectToText(mt);
            }
        }
Example #10
0
        private void trePhong_AfterSelect_1(object sender, TreeViewEventArgs e)
        {
            lblMay mt = null;

            if (trePhong.SelectedNode != null)        //có node chọn
            {
                if (trePhong.SelectedNode.Level == 2) //chọn nút con cấp 2
                {
                    mt = (lblMay)trePhong.SelectedNode.Tag;
                    LoadTreeViewToText(mt);//load dl từ treeview xuống textbox
                    objectToText(mt);
                }
                else if (trePhong.SelectedNode.Level == 1)//chọn nút con cấp 1
                {
                    String strMTinh = trePhong.SelectedNode.Tag.ToString();
                    IEnumerable <lblMay> lstmayTinhThuocPhong = objMay.GetMayTinhThuocPhongHoc(strMTinh);
                    dgrMayTinh.DataSource = lstmayTinhThuocPhong;
                    FormatDaTaGrid(dgrMayTinh);
                }
            }
        }
Example #11
0
 private void detach_lblMays(lblMay entity)
 {
     this.SendPropertyChanging();
     entity.lblPhong = null;
 }
Example #12
0
 private void attach_lblMays(lblMay entity)
 {
     this.SendPropertyChanging();
     entity.lblPhong = this;
 }
Example #13
0
 partial void DeletelblMay(lblMay instance);
Example #14
0
 partial void UpdatelblMay(lblMay instance);
Example #15
0
 partial void InsertlblMay(lblMay instance);