예제 #1
0
 private void DataTable_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         DataGrid row      = sender as DataGrid;
         dynamic  selected = row.SelectedItem;
         dynamic  intId    = selected.MANV;
         String   id       = intId.ToString();
         if (id != null)
         {
             using (QLSV_CANHANEntities db = new QLSV_CANHANEntities())
             {
                 var temp = db.FIND_NV(id);
                 foreach (var i in temp)
                 {
                     txtNV.Text       = i.MANV;
                     txtTen.Text      = i.HOTEN;
                     txtEmail.Text    = i.EMAIL;
                     txtLuong.Text    = NV_ALGORITHM.getLuong(i.LUONG);
                     txtUsername.Text = i.TENDN;
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("ERROR: " + ex.Message);
     }
 }
예제 #2
0
 private void LoginButton_Click(object sender, RoutedEventArgs e)
 {
     using (QLSV_CANHANEntities db = new QLSV_CANHANEntities())
     {
         SHA1Managed   sha1        = new SHA1Managed();
         var           hashMatKhau = sha1.ComputeHash(Encoding.UTF8.GetBytes(Password.Password));
         StringBuilder buildMK     = new StringBuilder();
         foreach (var i in hashMatKhau)
         {
             buildMK.Append(i.ToString());
         }
         var temp = db.LOGIN_NV(Username.Text, buildMK.ToString()).ToList();
         if (temp.Count() > 0)
         {
             string maNV = "";
             foreach (var i in temp)
             {
                 maNV = i.MANV;
                 break;
             }
             QL_NV ql = new QL_NV(maNV);
             ql.Show();
             this.Close();
             return;
         }
         var tempSV = db.LOGIN_SV(Username.Text, buildMK.ToString()).ToList();
         if (tempSV.Count() > 0)
         {
             string maNV = "";
             foreach (var i in tempSV)
             {
                 maNV = i.MASV;
                 break;
             }
             QL_NV ql = new QL_NV(maNV);
             ql.Show();
             this.Close();
             return;
         }
     }
 }
예제 #3
0
 private void xoaBtn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtNV.Text))
         {
             throw new Exception("String empty");
         }
         using (QLSV_CANHANEntities db = new QLSV_CANHANEntities())
         {
             var temp = (from p in db.NHANVIENs
                         where txtNV.Text == p.MANV
                         select p).SingleOrDefault();
             db.NHANVIENs.Remove(temp);
             db.SaveChanges();
         }
         dataTable.Items.Clear();
         loadData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }