コード例 #1
0
        private void SaveWorkExp()
        {
            try
            {
                foreach (var xe in db.t_TempEmpWorkExp.Where(p => p.EmpID == adminusers.Text))
                {
                    compName2     = xe.CompanyName;
                    compAddress2  = xe.CompanyAddress;
                    compPosition2 = xe.Position;
                    compFrom2     = Convert.ToString(xe.DateFrom);
                    compTo2       = Convert.ToString(xe.DateTo);

                    var newexp = new t_EmpWorkExperience();
                    newexp.EmpID          = NewEmpID;
                    newexp.CompanyName    = compName2;
                    newexp.CompanyAddress = compAddress2;
                    newexp.Position       = compPosition2;
                    newexp.DateFrom       = Convert.ToDateTime(compFrom2);
                    newexp.DateTo         = Convert.ToDateTime(compTo2);;
                    newexp.LastUpdate     = DateTime.Now;
                    db.t_EmpWorkExperience.Add(newexp);
                }
                db.SaveChanges();
                removeTempExperience();
            }
            catch { }
        }
コード例 #2
0
 private void gridWorkExp_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
 {
     try
     {
         var work = new t_EmpWorkExperience();
         work.EmpID          = EmpID.Text;
         work.CompanyName    = compName;
         work.CompanyAddress = compAddress;
         work.DateFrom       = Convert.ToDateTime(compFrom);;
         work.DateTo         = Convert.ToDateTime(compTo);;
         work.Position       = compPosition;
         work.LastUpdate     = DateTime.Now;
         e.NewObject         = work;
         db.t_EmpWorkExperience.Add(work);
     }
     catch { }
 }
コード例 #3
0
        private void gridWorkExp_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
        {
            if (e.EditAction == GridViewEditAction.Cancel)
            {
                return;
            }
            if (e.EditOperationType == GridViewEditOperationType.Insert)
            {
                try
                {
                    db.SaveChanges();
                    bindWorkExp();
                }
                catch { }
            }
            else if (e.EditOperationType == GridViewEditOperationType.Edit)
            {
                try
                {
                    foreach (var data in gridWorkExp.SelectedItems)
                    {
                        t_EmpWorkExperience myData = data as t_EmpWorkExperience;
                        compName     = myData.CompanyName;
                        compAddress  = myData.CompanyAddress;
                        compPosition = myData.Position;
                        compFrom     = Convert.ToString(myData.DateFrom);
                        compTo       = Convert.ToString(myData.DateTo);
                    }

                    //t_EmpWorkExperience workexp = db.t_EmpWorkExperience.First(p => p.EmpID == EmpID.Text);
                    var workexp = db.t_EmpWorkExperience.Where(p => p.EmpID == EmpID.Text).Where(x => x.CompanyName == compName).FirstOrDefault();
                    //workexp.CompanyName = compName;

                    workexp.CompanyAddress  = compAddress;
                    workexp.Position        = compPosition;
                    workexp.DateFrom        = Convert.ToDateTime(compFrom);
                    workexp.DateTo          = Convert.ToDateTime(compTo);
                    db.Entry(workexp).State = EntityState.Modified;
                    db.SaveChanges();
                    bindWorkExp();
                }
                catch { }
            }
        }
コード例 #4
0
 private void gridWorkExp_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Delete)
         {
             foreach (var data in gridWorkExp.SelectedItems)
             {
                 t_EmpWorkExperience myData = data as t_EmpWorkExperience;
                 var delete = db.t_EmpWorkExperience.Where(p => p.EmpID == EmpID.Text && p.CompanyName == myData.CompanyName).FirstOrDefault();
                 db.t_EmpWorkExperience.Remove(delete);
                 db.SaveChanges();
             }
             bindWorkExp();
         }
         else
         {
             return;
         }
     }
     catch { }
 }