Exemplo n.º 1
0
        private void btn_xoa_Click(object sender, EventArgs e)
        {
            NHANVIEN nv   = MyDb.GetInstance().NHANVIENs.Where(p => p.MaNV == txt_MaNV.Text.Trim()).SingleOrDefault();
            User     user = MyDb.GetInstance().Users.Where(p => p.MaNV == nv.MaNV).SingleOrDefault();

            MyDb.GetInstance().Users.Remove(user);
            nhanvienBLL.Delete(nv);

            Shownhanvien(nhanvienBLL.GetAll());
        }
Exemplo n.º 2
0
        void LoadData()
        {
            var result = MyDb.GetInstance().HOCBONGs.Select(a => new { a.Mahb, a.Tenhb, a.Sotien });

            dtgvHB.DataSource = result.ToList();

            dtgvHB.Columns[0].HeaderText = "Mã HB";
            dtgvHB.Columns[1].HeaderText = "Tên HB";
            dtgvHB.Columns[2].HeaderText = "Số tiền";
        }
Exemplo n.º 3
0
        public void saveConnectionstring(string yourInitialCatalog, string yourDataSource, string userName, string passWord)
        {
            DEMOQLKTXEntities selectedDb = MyDb.GetInstance();

            selectedDb.ChangeDatabase(initialCatalog: yourInitialCatalog.Trim(), dataSource: yourDataSource.Trim(), userName, passWord);

            User firstUser = selectedDb.Users.FirstOrDefault();

            if (firstUser == null)
            {
                MessageBox.Show("Error");
            }

            // WriteAllText creates a file, writes the specified string to the file,
            // and then closes the file. You do NOT need to call Flush() or Close().
            System.IO.File.WriteAllText("ConnectString.txt", selectedDb.Database.Connection.ConnectionString);
        }
Exemplo n.º 4
0
        private void dtgvData1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var DataJoin = from sv in MyDb.GetInstance().SINHVIENs
                           where sv.Mahb == txbID.Text
                           select new
            {
                sv.Mahb,
                sv.Masv,
                sv.Hoten,
                sv.Gioitinh,
                sv.Sdt
            };

            dtgvSV.DataSource            = DataJoin.ToList();
            dtgvSV.Columns[0].HeaderText = "Mã HB";
            dtgvSV.Columns[1].HeaderText = "Mã số SV";
            dtgvSV.Columns[2].HeaderText = "Họ Tên";
            dtgvSV.Columns[3].HeaderText = "Giới Tính";
            dtgvSV.Columns[4].HeaderText = "SĐT";
        }
Exemplo n.º 5
0
        int count = 0;//Dùng để trờ về trang ds phòng sau khi xem ds sv mỗi phòng

        #region Method
        void LoadPhong()
        {
            List <PHONG> dsp = PhongBLL.GetAll();

            foreach (PHONG item in ktx.PHONGs)
            {
                var dssv = MyDb.GetInstance().HOPDONGs.Where(x => x.Sophong == item.Sophong).Count();

                Button button1 = new Button();
                //
                // button1
                //
                button1.BackColor = System.Drawing.Color.DarkRed;
                button1.ForeColor = System.Drawing.Color.Coral;
                button1.Location  = new System.Drawing.Point(463, 10);
                button1.Name      = "button1";
                button1.Size      = new System.Drawing.Size(75, 23);
                button1.TabIndex  = 40;
                button1.Text      = "button1";
                button1.UseVisualStyleBackColor = false;
                IconButton iBtnPhong = new IconButton();
                if (item.LoaiPhong == "Nam")
                {
                    #region Phòng Nam
                    //Design button bằng code
                    iBtnPhong.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(137)))), ((int)(((byte)(255)))));
                    iBtnPhong.FlatAppearance.BorderSize = 0;
                    iBtnPhong.FlatStyle  = System.Windows.Forms.FlatStyle.Flat;
                    iBtnPhong.Flip       = FontAwesome.Sharp.FlipOrientation.Normal;
                    iBtnPhong.Font       = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    iBtnPhong.ForeColor  = System.Drawing.Color.White;
                    iBtnPhong.IconChar   = FontAwesome.Sharp.IconChar.Male;
                    iBtnPhong.IconColor  = System.Drawing.Color.White;
                    iBtnPhong.IconSize   = 40;
                    iBtnPhong.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                    iBtnPhong.Location   = new System.Drawing.Point(403, 245);
                    iBtnPhong.Name       = "iconButton1";
                    iBtnPhong.Rotation   = 0D;
                    iBtnPhong.Size       = new System.Drawing.Size(123, 70);
                    iBtnPhong.TabIndex   = 15;
                    iBtnPhong.Text       = item.Sophong + "\r\n" + dssv.ToString() + "/" + item.Sluongsv.ToString() + " SV\r\n";
                    iBtnPhong.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
                    iBtnPhong.UseVisualStyleBackColor = false;
                    #endregion
                }
                else
                {
                    #region Phòng Nữ
                    iBtnPhong.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(77)))), ((int)(((byte)(214)))));
                    iBtnPhong.FlatAppearance.BorderSize = 0;
                    iBtnPhong.FlatStyle  = System.Windows.Forms.FlatStyle.Flat;
                    iBtnPhong.Flip       = FontAwesome.Sharp.FlipOrientation.Normal;
                    iBtnPhong.Font       = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    iBtnPhong.ForeColor  = System.Drawing.Color.White;
                    iBtnPhong.IconChar   = FontAwesome.Sharp.IconChar.Female;
                    iBtnPhong.IconColor  = System.Drawing.Color.White;
                    iBtnPhong.IconSize   = 40;
                    iBtnPhong.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                    iBtnPhong.Location   = new System.Drawing.Point(403, 245);
                    iBtnPhong.Name       = "iconButton1";
                    iBtnPhong.Rotation   = 0D;
                    iBtnPhong.Size       = new System.Drawing.Size(123, 70);
                    iBtnPhong.TabIndex   = 15;
                    iBtnPhong.Text       = item.Sophong + "\r\n" + dssv.ToString() + "/" + item.Sluongsv.ToString() + " SV\r\n";
                    iBtnPhong.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
                    iBtnPhong.UseVisualStyleBackColor = false;
                    #endregion
                }
                iBtnPhong.Click += IBtnPhong_Click;
                //Design button phòng --> gắn event
                button1.Click += Button1_Click;
                button1.Tag    = item;
                //
                iBtnPhong.Tag = item;
                PanelPhong.Controls.Add(iBtnPhong);
            }
        }
Exemplo n.º 6
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var result = MyDb.GetInstance().SINHVIENs.Select(x => new { x.MaDTUT, x.Hoten, x.Masv, x.Cmnd, x.Ngaysinh });

            dGVdsSinhVien.DataSource = result.ToList();
        }