Example #1
0
        /// <summary>
        /// select dữ liệu từ server
        /// </summary>
        public void SelectData()
        {
            try
            {
                Server_Client.Client cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                Entities.NhanVien ncc = new Entities.NhanVien("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                Entities.NhanVien[] ncc1 = new Entities.NhanVien[1];
                clientstrem = cl.SerializeObj(this.client1, "NhanVien", ncc);
                // đổ mảng đối tượng vào datagripview
                ncc1 = (Entities.NhanVien[])cl.DeserializeHepper1(clientstrem, ncc1);
                if (ncc1 == null)
                {
                    hienthi = new Entities.NhanVien[0];
                    dtgvncc.DataSource = new Entities.NhanVien[0];
                    return;
                }

                Entities.NhanVien[] ncc2 = new Entities.NhanVien[ncc1.Length];
                int sotang = 0;
                for (int j = 0; j < ncc1.Length; j++)
                {
                    if (ncc1[j].Deleted == false)
                    {
                        ncc2[sotang] = ncc1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.NhanVien[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = ncc2[j];
                    }
                }
                else
                {
                    hienthi = new Entities.NhanVien[0];
                    dtgvncc.DataSource = new Entities.NhanVien[0];
                    return;
                }
                dtgvncc.DataSource = hienthi;
                dtgvncc.Rows[0].Selected = true;

            }
            catch (Exception ex)
            {
            }
            finally
            {

                fix();

            }
        }
Example #2
0
        /// <summary>
        /// select dữ liệu từ server
        /// </summary>
        public void SelectData()
        {
            try
            {
                Server_Client.Client cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                Entities.NhanVien ncc = new Entities.NhanVien("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                Entities.NhanVien[] ncc1 = new Entities.NhanVien[1];
                clientstrem = cl.SerializeObj(this.client1, "NhanVien", ncc);
                // đổ mảng đối tượng vào datagripview
                ncc1 = (Entities.NhanVien[])cl.DeserializeHepper1(clientstrem, ncc1);
                if (ncc1 == null)
                {
                    hienthi            = new Entities.NhanVien[0];
                    dtgvncc.DataSource = new Entities.NhanVien[0];
                    return;
                }

                Entities.NhanVien[] ncc2 = new Entities.NhanVien[ncc1.Length];
                int sotang = 0;
                for (int j = 0; j < ncc1.Length; j++)
                {
                    if (ncc1[j].Deleted == false)
                    {
                        ncc2[sotang] = ncc1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.NhanVien[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = ncc2[j];
                    }
                }
                else
                {
                    hienthi            = new Entities.NhanVien[0];
                    dtgvncc.DataSource = new Entities.NhanVien[0];
                    return;
                }
                dtgvncc.DataSource       = hienthi;
                dtgvncc.Rows[0].Selected = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                fix();
            }
        }
Example #3
0
        private void btnThemNV_Click(object sender, EventArgs e)
        {
            if (txtHoTen.Text.Length > 50)
            {
                MessageBox.Show("Vui lòng nhập họ tên ít hơn 50 ký tự", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string gioiTinh;

            if (rdoNu.Checked == false && rdoNam.Checked == false)
            {
                MessageBox.Show("Vui lòng chọn giới tính cho nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                if (rdoNu.Checked)
                {
                    gioiTinh = "Nu";
                }
                else
                {
                    gioiTinh = "Nam";
                }
            }

            Entities.NhanVien nhanVien = new Entities.NhanVien(
                NhanVienBLL.AutoMaNV().ToString(),
                txtHoTen.Text,
                gioiTinh,
                dtNgaySinh.Value,
                txtEmail.Text,
                txtDiaChi.Text,
                txtSDT.Text);

            try
            {
                if (NhanVienBLL.ThemNV(nhanVien))
                {
                    MessageBox.Show("Đã thêm nhân viên thành công", "Thông báo", MessageBoxButtons.OK);
                    CleanInput();
                }
                else
                {
                    MessageBox.Show("Lỗi chưa xác định", "Thông báo", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 public void SelectNhanVien()
 {
     try
     {
         cl           = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.NhanVien ctxh = new Entities.NhanVien("Select");
         clientstrem = cl.SerializeObj(this.client1, "NhanVien", ctxh);
         nv          = (Entities.NhanVien[])cl.DeserializeHepper1(clientstrem, nv);
         if (nv == null)
         {
             nv = new Entities.NhanVien[0];
             return;
         }
     }
     catch
     {
     }
 }
Example #5
0
        private void cmbMaNhanVien_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbMaNhanVien.Items.Clear();
             client = new Server_Client.Client();
             this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

             Entities.NhanVien kh = new Entities.NhanVien();
             kh = new Entities.NhanVien("Select");
             networkStream = client.SerializeObj(this.tcpClient, "NhanVien", kh);
             Entities.NhanVien[] kh1 = new Entities.NhanVien[1];
             kh1 = (Entities.NhanVien[])client.DeserializeHepper1(networkStream, kh1);

             if (kh1.Length > 0)
             {
                 int sl = kh1.Length;
                 for (int i = 0; i < sl; i++)
                 {
                     if (kh1[i].Deleted == false)
                         cmbMaNhanVien.Items.Add(kh1[i].MaNhanVien);
                 }
             }
        }
Example #6
0
        private void cmbMaNhanVien_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbMaNhanVien.Items.Clear();
            client         = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.NhanVien kh = new Entities.NhanVien();
            kh            = new Entities.NhanVien("Select");
            networkStream = client.SerializeObj(this.tcpClient, "NhanVien", kh);
            Entities.NhanVien[] kh1 = new Entities.NhanVien[1];
            kh1 = (Entities.NhanVien[])client.DeserializeHepper1(networkStream, kh1);

            if (kh1.Length > 0)
            {
                int sl = kh1.Length;
                for (int i = 0; i < sl; i++)
                {
                    if (kh1[i].Deleted == false)
                    {
                        cmbMaNhanVien.Items.Add(kh1[i].MaNhanVien);
                    }
                }
            }
        }
        public int Save(Entities.NhanVien Staff, bool PasswordNotHash)
        {
            if (Staff.MaNV != 0)
            {
                NhanVien original = Find(Staff.MaNV);
                original.TenTK   = Staff.TenTK;
                original.MatKhau = PasswordNotHash == true ? Staff.MatKhau : Lib.Md5Sha1Encrypt.SHA1Hashing(Staff.MatKhau);
                original.Email   = Staff.Email;
                original.TenNV   = Staff.TenNV;
                original.DiaChi  = Staff.DiaChi;
                original.CMND    = Staff.CMND;
                original.SDT     = Staff.SDT;
                original.MaNhom  = Staff.MaNhom;

                return(1);
            }

            int countBefore = staffs.Count;

            Staff.MatKhau = Lib.Md5Sha1Encrypt.SHA1Hashing(Staff.MatKhau);
            staffs.Add(Staff);

            return(staffs.Count - countBefore);
        }
Example #8
0
 /// <summary>
 /// xử lý tìm kiếm
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtimkiem3.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dtgvncc.DataSource = new Entities.NhanVien[0];
             return;
         }
         int soluong = 0;
         if (rdbtimkiem1.Checked == true)
         {
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].TenNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text);
                 if (kiemtra >= 0)
                 {
                     soluong++;
                 }
             }
             if (soluong == 0)
             {
                 dtgvncc.DataSource = new Entities.NhanVien[0];
                 return;
             }
             Entities.NhanVien[] hienthitheoid = new Entities.NhanVien[soluong];
             soluong = 0;
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].TenNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text);
                 if (kiemtra >= 0)
                 {
                     hienthitheoid[soluong] = hienthi[i];
                     soluong++;
                 }
             }
             dtgvncc.DataSource = hienthitheoid;
         }
         if (rdbtimkiem2.Checked == true)
         {
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].MaNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                 if (kiemtra >= 0)
                 {
                     soluong++;
                 }
             }
             if (soluong == 0)
             {
                 dtgvncc.DataSource = new Entities.NhanVien[0];
                 return;
             }
             Entities.NhanVien[] hienthitheoma = new Entities.NhanVien[soluong];
             soluong = 0;
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].MaNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                 if (kiemtra >= 0)
                 {
                     hienthitheoma[soluong] = hienthi[i];
                     soluong++;
                 }
             }
             dtgvncc.DataSource = hienthitheoma;
         }
     }
     finally
     {
         fix();
     }
 }
Example #9
0
 /// <summary>
 /// xử lý tìm kiếm
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtimkiem3.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dtgvncc.DataSource = new Entities.NhanVien[0];
             return;
         }
         int soluong = 0;
         if (rdbtimkiem1.Checked == true)
         {
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].TenNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text);
                 if (kiemtra >= 0)
                 {
                     soluong++;
                 }
             }
             if (soluong == 0)
             {
                 dtgvncc.DataSource = new Entities.NhanVien[0];
                 return;
             }
             Entities.NhanVien[] hienthitheoid = new Entities.NhanVien[soluong];
             soluong = 0;
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].TenNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text);
                 if (kiemtra >= 0)
                 {
                     hienthitheoid[soluong] = hienthi[i];
                     soluong++;
                 }
             }
             dtgvncc.DataSource = hienthitheoid;
         }
         if (rdbtimkiem2.Checked == true)
         {
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].MaNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                 if (kiemtra >= 0)
                 {
                     soluong++;
                 }
             }
             if (soluong == 0)
             {
                 dtgvncc.DataSource = new Entities.NhanVien[0];
                 return;
             }
             Entities.NhanVien[] hienthitheoma = new Entities.NhanVien[soluong];
             soluong = 0;
             for (int i = 0; i < hienthi.Length; i++)
             {
                 int kiemtra = hienthi[i].MaNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                 if (kiemtra >= 0)
                 {
                     hienthitheoma[soluong] = hienthi[i];
                     soluong++;
                 }
             }
             dtgvncc.DataSource = hienthitheoma;
         }
     }
     finally
     {
         fix();
     }
 }
 public void SelectNhanVien()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.NhanVien ctxh = new Entities.NhanVien("Select");
         clientstrem = cl.SerializeObj(this.client1, "NhanVien", ctxh);
         nv = (Entities.NhanVien[])cl.DeserializeHepper1(clientstrem, nv);
         if (nv == null)
         {
             nv = new Entities.NhanVien[0];
             return;
         }
     }
     catch
     {
     }
 }
        public void SelectNV()
        {
            try
            {
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.NhanVien kh = new Entities.NhanVien();
                kh = new Entities.NhanVien("Select");
                Entities.NhanVien[] kh1 = new Entities.NhanVien[1];
                clientstrem = cl.SerializeObj(this.client1, "NhanVien", kh);
                kh1 = (Entities.NhanVien[])cl.DeserializeHepper1(clientstrem, kh1);
                if (kh1 == null)
                {
                    kh1 = new Entities.NhanVien[0];
                    return;
                }

                Entities.NhanVien[] pt2 = new Entities.NhanVien[kh1.Length];
                for (int j = 0; j < kh1.Length; j++)
                {

                    if (kh1[j].MaNhanVien == doituong)
                    {
                        lbhienthidiachi.Text = kh1[j].Email;
                        lbhienthima.Text = kh1[j].MaNhanVien;
                        lbhienthiten.Text = kh1[j].TenNhanVien;
                        break;
                    }
                }
            }
            catch { }
        }
 public int Save(Entities.NhanVien Entity)
 {
     return(Save(Entity, false));
 }