private void gridDependent_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            if (e.EditAction == GridViewEditAction.Cancel)
            {
                return;
            }
            if (e.EditOperationType == GridViewEditOperationType.Insert)
            {
                try
                {
                    db.SaveChanges();
                    bindDependents();
                }
                catch { }
            }
            else if (e.EditOperationType == GridViewEditOperationType.Edit)
            {
                // try
                //{
                int ss = 0;

                foreach (var data in gridDependent.SelectedItems)
                {
                    t_EmpDependents myData = data as t_EmpDependents;
                    depName         = myData.Name;
                    depBirthDate    = Convert.ToString(myData.BirthDate);
                    depRelationship = myData.Relationship;
                    depOccupation   = myData.Occupation;
                    depMaidenName   = myData.MaidenName;
                    ss = Convert.ToInt32(myData.DependentID);
                }

                var dep = db.t_EmpDependents.Where(x => x.DependentID == ss).FirstOrDefault();

                dep.BirthDate    = Convert.ToDateTime(depBirthDate);
                dep.Relationship = depRelationship;
                dep.Occupation   = depOccupation;
                dep.MaidenName   = depMaidenName;

                db.Entry(dep).State = EntityState.Modified;

                db.SaveChanges();

                bindDependents();
                // }
                //catch { }
            }
        }
Exemple #2
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 { }
            }
        }