Beispiel #1
0
        public int InsertEmployee(EmpInfo emp)
        {
            int t           = 0;
            var beforeCount = (from i
                               in Main.employees
                               select i).Count();

            employee obj = new employee();
            project  pro = new project();

            pro.projId     = emp.ProjectId;
            pro.projname   = emp.ProjectName;
            obj.empid      = emp.EmpId;
            obj.empname    = emp.EmpName;
            obj.empsalary  = emp.EmpSalary;
            obj.empAddress = emp.EmpAddress;
            obj.project    = pro;

            Main.employees.Add(obj);
            Main.SaveChanges();
            var afterCount = (from i
                              in Main.employees
                              select i).Count();

            if (afterCount > beforeCount)
            {
                t = 1;
            }
            else if (afterCount == beforeCount)
            {
                t = 0;
            }
            else
            {
                t = 2;
            }
            return(t);
        }