Пример #1
0
        public void SfDataGrid1_RowValidating(object sender, Syncfusion.UI.Xaml.Grid.RowValidatingEventArgs args)
        {
            CustomerDatabaseEntities context         = new CustomerDatabaseEntities();
            Employee_Details         newRecord       = args.RowData as Employee_Details;
            Employee_Details         currentEmployee = new Employee_Details();

            if (newRecord != null)
            {
                currentEmployee.employeeID = newRecord.employeeID;
                currentEmployee.email      = newRecord.email;
                currentEmployee.password   = newRecord.password;
                currentEmployee.firstName  = newRecord.firstName;
                currentEmployee.lastName   = newRecord.lastName;
            }


            using (context)
            {
                context.Employee_Details.Add(currentEmployee);
                context.SaveChanges();
                context.Dispose();
            }
        }
Пример #2
0
        private void Load()
        {
            while (true)
            {
                try
                {
                    TimeSheetManagementEntities dbContext = new TimeSheetManagementEntities();

                    string[] dataFile = File.ReadAllLines(fileWatchLocation);
                    int      i        = 1;
                    foreach (var data in dataFile.Skip(1))
                    {
                        var dataValues = data.Split(',');
                        var firstName  = dataValues[0];
                        //Employee_Details
                        int empId = 0;
                        if (dbContext.Employee_Details.Any())
                        {
                            empId = dbContext.Employee_Details.OrderByDescending(e => e.Employee_Id).FirstOrDefault().Employee_Id;
                        }
                        empId = empId + 1;
                        Employee_Details employee_Details = new Employee_Details();
                        employee_Details.Employee_Id       = empId;
                        employee_Details.First_Name        = dataValues[0];
                        employee_Details.Last_Name         = dataValues[1];
                        employee_Details.Designation       = dataValues[2];
                        employee_Details.Email_Id          = dataValues[3];
                        employee_Details.Start_Date        = Convert.ToDateTime(dataValues[4]);
                        employee_Details.Emp_Status        = dataValues[5].ToLower() == "active" ? true : false;
                        employee_Details.Employee_Type     = dataValues[6].ToLower() == "permanent" ? 1 : 0;
                        employee_Details.created_Date      = System.DateTime.Now;
                        employee_Details.Last_Updated_Date = System.DateTime.Now;
                        dbContext.Employee_Details.Add(employee_Details);
                        dbContext.SaveChanges();


                        // Address
                        Address address = new Address();
                        address.Address_Id        = empId;
                        address.Employee_Id       = empId;
                        address.City              = dataValues[7];
                        address.Address1          = dataValues[8];
                        address.PinCode           = Convert.ToInt32(dataValues[9]);
                        address.Geo_Id            = dbContext.Geo_Location.Where(geo => geo.Country.ToLower() == "india" && geo.State.ToLower() == "telangana").FirstOrDefault().Geo_Id;
                        address.created_Date      = System.DateTime.Now;
                        address.Last_Updated_Date = System.DateTime.Now;
                        dbContext.Addresses.Add(address);
                        dbContext.SaveChanges();
                        i++;
                    }

                    if (!Directory.Exists(archiveDirectory))
                    {
                        Directory.CreateDirectory(archiveDirectory);
                        if (File.Exists(fileWatchLocation))
                        {
                            File.Move(fileWatchLocation, archiveDirectory + "DataFile.csv" + "_" + System.DateTime.Now.ToString().Replace('-', '_').Replace(':', '_'));
                        }
                    }
                    else
                    {
                        if (File.Exists(fileWatchLocation))
                        {
                            File.Move(fileWatchLocation, archiveDirectory + "DataFile.csv" + "_" + System.DateTime.Now.ToString().Replace('-', '_').Replace(':', '_'));
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (!Directory.Exists(failureDirectory))
                    {
                        Directory.CreateDirectory(failureDirectory);
                        if (File.Exists(fileWatchLocation))
                        {
                            File.Move(fileWatchLocation, failureDirectory + "DataFile.csv" + "_" + System.DateTime.Now.ToString().Replace('-', '_').Replace(':', '_'));
                        }
                    }
                    else
                    {
                        if (File.Exists(fileWatchLocation))
                        {
                            File.Move(fileWatchLocation, failureDirectory + "DataFile.csv" + "_" + System.DateTime.Now.ToString().Replace('-', '_').Replace(':', '_'));
                        }
                    }
                }
                Task.Delay(10000);
            }
        }
Пример #3
0
        public bool AddEmployeeDetails(EmployeeDetailModel objEmployeeDetailModel)
        {
            try
            {
                var objEmployeeDetail = (from emp in ac.Employee_Details
                                         where emp.Emp_ID == objEmployeeDetailModel.Emp_ID
                                         select emp).FirstOrDefault();

                if (objEmployeeDetail != null)
                {
                    objEmployeeDetail.Emp_FirstName   = objEmployeeDetailModel.Emp_FirstName;
                    objEmployeeDetail.Emp_LastName    = objEmployeeDetailModel.Emp_LastName;
                    objEmployeeDetail.Emp_Email       = objEmployeeDetailModel.Emp_Email;
                    objEmployeeDetail.Emp_Designation = objEmployeeDetailModel.Emp_Designation;
                    objEmployeeDetail.UpdateDate      = DateTime.UtcNow;
                    objEmployeeDetail.UpdatedBy       = objEmployeeDetailModel.UpdatedBy;
                }
                else
                {
                    var objemployee = new Employee_Details()
                    {
                        Emp_ID          = objEmployeeDetailModel.Emp_ID,
                        Emp_FirstName   = objEmployeeDetailModel.Emp_FirstName,
                        Emp_LastName    = objEmployeeDetailModel.Emp_LastName,
                        Emp_Email       = objEmployeeDetailModel.Emp_Email,
                        Emp_Designation = objEmployeeDetailModel.Emp_Designation,
                        CreatedBy       = objEmployeeDetailModel.CreatedBy,
                        CreateDate      = DateTime.UtcNow,
                        UpdatedBy       = objEmployeeDetailModel.UpdatedBy,
                        UpdateDate      = DateTime.UtcNow
                    };
                    ac.Employee_Details.Add(objemployee);
                }

                ac.SaveChanges();

                //Add/edit technology details
                if (objEmployeeDetailModel != null && objEmployeeDetailModel.SeletedTechnology != null)
                {
                    var selectedIds       = objEmployeeDetailModel.SeletedTechnology.Split(',');
                    var lstEmployeeSkills = ac.Employee_Skill_Details.Where(eml => eml.Emp_ID == objEmployeeDetailModel.Emp_ID).ToList();
                    foreach (var objEmployeeSkill in lstEmployeeSkills)
                    {
                        ac.Employee_Skill_Details.Remove(objEmployeeSkill);
                    }
                    ac.SaveChanges();

                    foreach (var objTechnologyID in selectedIds)
                    {
                        var tid         = Convert.ToInt32(objTechnologyID);
                        var objempskill = new Employee_Skill_Details()
                        {
                            Emp_ID        = objEmployeeDetailModel.Emp_ID,
                            Technology_ID = tid,
                            UpdateDate    = DateTime.UtcNow,
                            CreateDate    = DateTime.UtcNow,
                            CreatedBy     = objEmployeeDetailModel.CreatedBy,
                            UpdatedBy     = objEmployeeDetailModel.UpdatedBy
                        };
                        ac.Employee_Skill_Details.Add(objempskill);
                    }
                    ac.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }