public void ChangePassword(Employee employee, bool needLog) { employee.Password = Cryptographer.CreateHash("SHA512Managed", employee.Password); _loginRepository.MakePersistent(employee); if (needLog) AuditLoginLog(new AuditLog { Action = LanguageReader.GetValue("Administration_Login_ChangePassword"), CurrentUser = employee.AgentId }); }
public static void Main( string[] args ) { // create five-element Employee array Employee[] employees = new Employee[ 5 ]; // initialize array with Employees employees[ 0 ] = new SalariedEmployee( "John", "Smith", "111-11-1111", 800M ); employees[ 1 ] = new HourlyEmployee( "Karen", "Price", "222-22-2222", 16.75M, 40M ); employees[ 2 ] = new CommissionEmployee( "Sue", "Jones", "333-33-3333", 10000M, .06M ); employees[ 3 ] = new BasePlusCommissionEmployee( "Bob", "Lewis", "444-44-4444", 5000M, .04M, 300M ); employees[4] = new PieceWorker("Tony", "Rosella", "555-55-5555", 15.50M, 20M); Console.WriteLine( "Employees processed polymorphically:\n" ); // generically process each element in array employees foreach ( var currentEmployee in employees ) { Console.WriteLine( currentEmployee ); // invokes ToString Console.WriteLine( "earned {0:C}\n", currentEmployee.Earnings() ); } // end foreach }
protected void btnSubmit_Click(object sender, EventArgs e) { Employee _Employee = new Employee(); _Employee.Name = Name.Text; _Employee.Contact_No = CN.Text; _Employee.NIC_No = NIC.Text; _Employee.Category = int.Parse(ddlCategory.SelectedValue); if (ddlCategory.SelectedItem.Text=="Stitcher") { _Employee.Contractor = int.Parse(ddlContractor.SelectedValue); } if (FileUpload.HasFile) { _Employee.Picture = GetImageBytes(); } _Employee.IsDeleted = false; lblMessage.Text = Employee_DA.insertEmployee(_Employee); if (lblMessage.Text == Constants.ALREADY_EXIST) { lblMessage.ForeColor = System.Drawing.Color.Red; } else { lblMessage.ForeColor = System.Drawing.Color.Green; ClearFields(); } }
public void Given_employee_is_risk_assessor_then_return_task() { //GIVEN var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Daily}; var riskAssessor = new RiskAssessor() { Id = 5596870, Employee = employee }; var riskAssessement = new HazardousSubstanceRiskAssessment() { RiskAssessor = riskAssessor, Status = RiskAssessmentStatus.Live}; var hazardousSubstanceRiskAssessmentFurtherControlMeasureTask = new HazardousSubstanceRiskAssessmentFurtherControlMeasureTask() { HazardousSubstanceRiskAssessment = riskAssessement, TaskCompletedDate = DateTime.Now, TaskStatus = TaskStatus.Completed }; riskAssessement.FurtherControlMeasureTasks.Add(hazardousSubstanceRiskAssessmentFurtherControlMeasureTask); _hsRiskAssessments.Add(riskAssessement); var target = new GetCompletedHazardousSubstanceRiskAssessmentFurtherControlMeasureTasksForEmployeeQuery(null); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(1)); }
public void ShouldGetByNumber() { new DatabaseTester().Clean(); var creator = new Employee("1", "1", "1", "1"); var order1 = new ExpenseReport(); order1.Submitter = creator; order1.Number = "123"; var report = new ExpenseReport(); report.Submitter = creator; report.Number = "456"; using (ISession session = DataContext.GetTransactedSession()) { session.SaveOrUpdate(creator); session.SaveOrUpdate(order1); session.SaveOrUpdate(report); session.Transaction.Commit(); } IContainer container = DependencyRegistrarModule.EnsureDependenciesRegistered(); var bus = container.GetInstance<Bus>(); ExpenseReport order123 = bus.Send(new ExpenseReportByNumberQuery {ExpenseReportNumber = "123"}).Result; ExpenseReport order456 = bus.Send(new ExpenseReportByNumberQuery {ExpenseReportNumber = "456"}).Result; Assert.That(order123.Id, Is.EqualTo(order1.Id)); Assert.That(order456.Id, Is.EqualTo(report.Id)); }
public DailyGrossRepositoryTest() { System.Configuration.ConnectionStringSettings cs = System.Configuration.ConfigurationManager.ConnectionStrings["aps"]; _container = new WindsorContainer(); _container .Register(Component.For<IDatabase>() .ImplementedBy<Database>() .DependsOn(Dependency.OnValue("provider", cs.ProviderName)) .DependsOn(Dependency.OnValue("connectionString", cs.ConnectionString)) //.DependsOn(Dependency.OnValue("provider", "System.Data.SqlClient")) //.DependsOn(Dependency.OnValue("connectionString", "Data Source=dev-s01;Initial Catalog=aps;User ID=sa;Password=sql@dm1n")) ) .Register(Component.For<IDailyGrossRepository>() .ImplementedBy<DailyGrossRepository>() ); _now = DateTime.Now; _ww = _now.WorkWeek(); _db = _container.Resolve<IDatabase>(); TestHelpers.TestData.Reset(_db); _employee = TestHelpers.TestData.GetEmployee(_db, "Tom"); _repos = _container.Resolve<IDailyGrossRepository>(); }
protected void Save(object sender, EventArgs e) { Employee emp = new Employee(); if (hdn.Value == "Edit") { if (ViewState["_idEdit"] != "") emp._id = ObjectId.Parse(ViewState["_idEdit"].ToString()); emp.empName = txtEmployeeName.Text; emp.empId = txtID.Text; emp.salary = Convert.ToDouble(txtSal.Text); emp.address = txtAddress.Text; emp.phone = txtPhn.Text; //dal.insert(emp); // emp._id = Xid; dal.updateEmployee(emp); LoadEMployee(); } else { //Employee emp = new Employee(); emp.empName = txtEmployeeName.Text; emp.empId = txtID.Text; emp.salary = Convert.ToDouble(txtSal.Text); emp.address = txtAddress.Text; emp.phone = txtPhn.Text; dal.insert(emp); LoadEMployee(); } }
public int Insert(Employee employee) { const string sql = @"INSERT INTO HR.Employee (FirstName, MiddleName, LastName, Title, ManagerKey, OfficePhone, CellPhone ) VALUES (@FirstName, @MiddleName, @LastName, @Title, @ManagerKey, @OfficePhone, @CellPhone ); SELECT SCOPE_IDENTITY() "; using (var con = new SqlConnection(m_ConnectionString)) { con.Open(); return con.ExecuteScalar<int>(sql, employee); } }
protected void btnSubmit_Click(object sender, EventArgs e) { Employee e1 = new Employee(); e1.FirstName = txtFname.Text; e1.MiddleName = txtMname.Text; e1.LastName = txtLname.Text; e1.Leaves = Convert.ToInt32(txtLeaves.Text); e1.PhoneNumber = txtPhoneNo.Text; e1.Position = txtPos.Text; e1.ZipCode = txtZip1.Text + "-" + txtZip2.Text; e1.State = txtState.Text; e1.Salary = Convert.ToDecimal(txtSal.Text); e1.Addreee = txtAdd.Text; e1.City = txtCity.Text; e1.Department = ddlDept.SelectedItem.Text; e1.EmailId = txtEmailId.Text; if (picUpload.HasFile) { string fileName = Path.GetFileName(picUpload.PostedFile.FileName); picUpload.PostedFile.SaveAs(Server.MapPath("Images/") + fileName); e1.Picture = fileName; } EmpBusiness eba = new EmpBusiness(); eba.insertNewEmployee(e1); string text2disp = "Emp Id "+x+" created successfully"; // string script = text2disp; Label2.Visible = true; Label2.Text = text2disp; clearst(); }
public void ShouldSearchBySpecificationWithCreator() { new DatabaseTester().Clean(); var creator1 = new Employee("1", "1", "1", "1"); var creator2 = new Employee("2", "2", "2", "2"); var order1 = new ExpenseReport(); order1.Submitter = creator1; order1.Number = "123"; var order2 = new ExpenseReport(); order2.Submitter = creator2; order2.Number = "456"; using (ISession session = DataContext.GetTransactedSession()) { session.SaveOrUpdate(creator1); session.SaveOrUpdate(creator2); session.SaveOrUpdate(order1); session.SaveOrUpdate(order2); session.Transaction.Commit(); } var specification = new ExpenseReportSpecificationQuery{Submitter = creator1}; IContainer container = DependencyRegistrarModule.EnsureDependenciesRegistered(); var bus = container.GetInstance<Bus>(); MultipleResult<ExpenseReport> result = bus.Send(specification); ExpenseReport[] reports = result.Results; Assert.That(reports.Length, Is.EqualTo(1)); Assert.That(reports[0].Id, Is.EqualTo(order1.Id)); }
public void Example() { #region Usage Employee joe = new Employee(); joe.Name = "Joe Employee"; Employee mike = new Employee(); mike.Name = "Mike Manager"; joe.Manager = mike; // mike is his own manager // ShouldSerialize will skip this property mike.Manager = mike; string json = JsonConvert.SerializeObject(new[] { joe, mike }, Formatting.Indented); Console.WriteLine(json); // [ // { // "Name": "Joe Employee", // "Manager": { // "Name": "Mike Manager" // } // }, // { // "Name": "Mike Manager" // } // ] #endregion }
public static int SaveEmployee(Employee employee) { try { if (employee == null) throw new ArgumentNullException("employee"); using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("spSaveEmployee", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Clear(); command.Parameters.Add(new SqlParameter("@Name", employee.Name)); command.Parameters.Add(new SqlParameter("@Gender", employee.Gender)); command.Parameters.Add(new SqlParameter("@DateOfBirth", employee.DateOfBirth)); command.Parameters.Add(new SqlParameter("@EmployeeType", employee.EmployeeType)); if (employee.EmployeeType == EmployeeType.FullTimeEmployee) { command.Parameters.Add(new SqlParameter("@AnnualySalary", ((FullTimeEmployee)employee).AnnualySalary)); } else if (employee.EmployeeType == EmployeeType.PartTimeEmployee) { command.Parameters.Add(new SqlParameter("@HourlyPay", ((PartTimeEmployee)employee).HourlyPay)); command.Parameters.Add(new SqlParameter("@HoursWorked", ((PartTimeEmployee)employee).HoursWorked)); } return command.ExecuteNonQuery(); } } catch (Exception ex) { throw; } }
public static void Delete(Employee employee) { context.Employees.Remove(employee); context.SaveChanges(); //var projects = employee.Projects; //var departments = employee.Departments; //var managedEmployees = employee.Employees1; //var managedDepartments = Context.Departments // .Where(d => d.ManagerID == employee.ManagerID); //foreach (var managedDepartment in managedDepartments) //{ // managedDepartment.ManagerID = 0; //} //foreach (var managedEmployee in managedEmployees) //{ // managedEmployee.ManagerID = null; //} //foreach (var project in projects) //{ // project.Employees.Remove(employee); //} //foreach (var department in departments) //{ // department.Employees1.Remove(employee); //} //Context.Employees.Remove(employee); //Context.SaveChanges(); }
private static void Setup() { var employee = new Employee("jpalermo", "Jeffrey", "Palermo", "jeffrey @ clear dash measure.com"); using (ISession session = DataContext.GetTransactedSession()) { session.Save(employee); session.Transaction.Commit(); } var startingDate = new DateTime(1974, 8, 4); for (int i = 0; i < 25; i++) { RunToDraft(new NumberGenerator().GenerateNumber(), employee, 13*i, startingDate.AddMinutes(i), "Save"); } for (int i = 0; i < 25; i++) { RunToDraft(new NumberGenerator().GenerateNumber(), employee, 13*i, startingDate.AddMinutes(i), "Save", "Submit"); } for (int i = 0; i < 25; i++) { RunToDraft(new NumberGenerator().GenerateNumber(), employee, 13*i, startingDate.AddMinutes(i), "Save", "Submit", "Approve"); } for (int i = 0; i < 25; i++) { RunToDraft(new NumberGenerator().GenerateNumber(), employee, 13*i, startingDate.AddMinutes(i), "Save", "Submit", "Approve"); } }
public void ShouldExecuteDraftTransition() { new DatabaseTester().Clean(); var report = new ExpenseReport(); report.Number = "123"; report.Status = ExpenseReportStatus.Draft; var employee = new Employee("jpalermo", "Jeffrey", "Palermo", "jeffrey @ clear dash measure.com"); report.Submitter = employee; report.Approver = employee; using (ISession session = DataContext.GetTransactedSession()) { session.SaveOrUpdate(employee); session.SaveOrUpdate(report); session.Transaction.Commit(); } var command = new ExecuteTransitionCommand(report, "Save", employee, new DateTime(2001, 1, 1)); IContainer container = DependencyRegistrarModule.EnsureDependenciesRegistered(); var bus = container.GetInstance<Bus>(); ExecuteTransitionResult result = bus.Send(command); result.NewStatus.ShouldEqual("Drafting"); }
public static Employee AddEmployee(this EmployeeData employeeData, string firstName, string lastName,bool isenabled) { int customerNumber = employeeData.Any() ? employeeData.Max(m => m.EmployeeNumber) + 1 : EmployeeData.EmployeeNumberSeed; Employee employee = new Employee() { EmployeeNumber = customerNumber, FirstName = firstName, LastName = lastName, IsEnabled=isenabled}; employeeData.Add(employee); return employee; }
private static void RunToDraft(string number, Employee employee, int total, DateTime startingDate, params string[] commandsToRun) { var report = new ExpenseReport(); report.Number = number; report.Status = ExpenseReportStatus.Draft; report.Submitter = employee; report.Approver = employee; report.Total = total; using (ISession session = DataContext.GetTransactedSession()) { session.SaveOrUpdate(report); session.Transaction.Commit(); } IContainer container = DependencyRegistrarModule.EnsureDependenciesRegistered(); var bus = container.GetInstance<Bus>(); for (int j = 0; j < commandsToRun.Length; j++) { DateTime timestamp = startingDate.AddSeconds(j); var command = new ExecuteTransitionCommand(report, commandsToRun[j], employee, timestamp); bus.Send(command); } }
internal Employee GetEmployeedetails(string name) { var empEntity = new Employee(); using (var site = new SPSite(SPContext.Current.Site.Url)) { using (var web = site.OpenWeb()) { SPUser user = web.CurrentUser; hdnCurrentUsername.Value = user.Name; SPListItemCollection currentUserDetails = GetListItemCollection(web.Lists[Utilities.EmployeeScreen], "Employee Name", name, "Status", "Active"); foreach (SPListItem currentUserDetail in currentUserDetails) { empEntity.EmpId = currentUserDetail[Utilities.EmployeeId].ToString(); empEntity.EmployeeType = currentUserDetail[Utilities.EmployeeType].ToString(); empEntity.Department = currentUserDetail[Utilities.Department].ToString(); empEntity.Desigination = currentUserDetail[Utilities.Designation].ToString(); empEntity.DOJ = DateTime.Parse(currentUserDetail[Utilities.DateofJoin].ToString()); empEntity.ManagerWithID = currentUserDetail[Utilities.Manager].ToString(); var spv = new SPFieldLookupValue(currentUserDetail[Utilities.Manager].ToString()); empEntity.Manager = spv.LookupValue; } } } return empEntity; }
public void Given_employee_is_asignee_and_notification_frequency_is_set_to_weekly_then_return_tasks_since_previous_week() { var employee = new Employee() { NotificationType = NotificationType.Weekly, NotificationFrequecy = (int)System.DayOfWeek.Wednesday }; var responsibility = new Responsibility() { }; responsibility.ResponsibilityTasks.Add( new ResponsibilityTask() { TaskAssignedTo = employee, TaskCompletionDueDate = DateTime.Now.AddDays(-2) }); responsibility.ResponsibilityTasks.Add(new ResponsibilityTask() { TaskAssignedTo = employee, TaskCompletionDueDate = DateTime.Now.AddDays(-5) }); responsibility.ResponsibilityTasks.Add(new ResponsibilityTask() { TaskAssignedTo = employee, TaskCompletionDueDate = DateTime.Now.AddDays(-15) }); _responsibilities.Add(responsibility); var target = new GetOverdueResponsibilitiesTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(2)); }
static void Main(string[] args) { string msg = string.Empty; EmployeeBLL objEmployeeBLL = new EmployeeBLL(); Employee objEmployee = new Employee(); objEmployee.Name = "Fahad"; objEmployee.Designation = "Software Engineer"; objEmployee.BloodGroup = "O+"; try { msg = objEmployeeBLL.SaveEmployee(objEmployee); Console.WriteLine(msg); } catch(Exception exp) { msg = exp.Message; Console.WriteLine(msg); } try { DisplayEmployeeInfo(objEmployeeBLL.GetAllEmployee()); } catch(Exception exp) { msg = exp.Message; Console.WriteLine(msg); } Console.ReadKey(); }
static void Main() { int n = int.Parse(Console.ReadLine()); int m = int.Parse(Console.ReadLine()); Dictionary<string, Employee> employees = new Dictionary<string, Employee>(); string bossName = Console.ReadLine(); Employee bigBoss = new Employee(bossName); employees.Add(bossName, bigBoss); for (int i = 1; i < n; i++) { string name = Console.ReadLine(); Employee employee = new Employee(name); employees.Add(name, employee); } for (int i = 0; i < m; i++) { string line = Console.ReadLine(); string[] names = line.Split(' '); string superiorName = names[0]; for (int j = 1; j < names.Length; j++) { employees[superiorName].Subrdinates.Add(employees[names[j]]); } } DFS(bigBoss); Console.WriteLine(allSalaries); }
public static void should_rollback_everything() { try { UnitOfWork.Do(uow => { //arrange var employee = new Employee { Id = "667", FirstName = "Jack", LastName = "Black" }; uow.Repo<Employee>().Insert(employee); //act UnitOfWork.Do(nested => { throw new Exception("Horrible thing"); }); }); } catch (Exception) { } UnitOfWork.Do(uow => { var found = uow.Repo<Employee>().AsQueryable().FirstOrDefault(t => t.Id == "667"); //assert found.Should().BeNull(); }); }
public static void Main() { const char DELIM = ','; const string FILENAME = "EmployeeData.txt"; Employee emp = new Employee(); FileStream inFile = new FileStream(FILENAME, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(inFile); string recordIn; string[] fields; Console.WriteLine("\n{0,-5}{1,-12}{2,8}\n", "Num", "Name", "Salary"); recordIn = reader.ReadLine(); while(recordIn != null) { fields = recordIn.Split(DELIM); emp.EmpNum = Convert.ToInt32(fields[0]); emp.Name = fields[1]; emp.Salary = Convert.ToDouble(fields[2]); Console.WriteLine("{0,-5}{1,-12}{2,8}", emp.EmpNum, emp.Name, emp.Salary.ToString("C")); recordIn = reader.ReadLine(); } reader.Close(); inFile.Close(); }
private double GetWeeklySalary(Employee employee) { double weeklySalary = employee.YearlySalary/52; weeklySalary -= weeklySalary * 0.065; return weeklySalary; }
public void Given_FCM_is_reocurring_weekly_Then_when_it_is_completed_Then_following_task_should_be_created_with_due_date_a_week_later() { var assignedTo = new Employee { Id = Guid.NewGuid() }; var user1= new UserForAuditing { Id = Guid.NewGuid() }; var user2= new UserForAuditing { Id = Guid.NewGuid() }; var furtherControlMeasureTask = HazardousSubstanceRiskAssessmentFurtherControlMeasureTask.Create( "FCM", "Test FCM", "Description", new DateTime(2012, 09, 13), TaskStatus.Outstanding, assignedTo, user1, new System.Collections.Generic.List<CreateDocumentParameters> { new CreateDocumentParameters { DocumentLibraryId = 2000L, Description = "Test File 1", DocumentType = new DocumentType {Id = 5L}, Filename = "Test File 1.txt" } }, new TaskCategory {Id = 9L}, (int) TaskReoccurringType.Weekly, new DateTime(2013, 09, 13), false, false, false, false, Guid.NewGuid()); furtherControlMeasureTask.Complete("Test Comments", new List<CreateDocumentParameters>(), new List<long>(), user2, null, DateTime.Now); Assert.IsNotNull(furtherControlMeasureTask.FollowingTask); Assert.AreEqual(furtherControlMeasureTask, furtherControlMeasureTask.FollowingTask. PrecedingTask); Assert.AreEqual(furtherControlMeasureTask.Reference, furtherControlMeasureTask.FollowingTask.Reference); Assert.AreEqual(furtherControlMeasureTask.Title, furtherControlMeasureTask.FollowingTask.Title); Assert.AreEqual(furtherControlMeasureTask.Description, furtherControlMeasureTask.FollowingTask.Description); Assert.AreEqual(new DateTime(2012, 09, 20), furtherControlMeasureTask.FollowingTask.TaskCompletionDueDate); Assert.AreEqual(furtherControlMeasureTask.TaskAssignedTo.Id, furtherControlMeasureTask.FollowingTask.TaskAssignedTo.Id); Assert.AreEqual(user2.Id, furtherControlMeasureTask.FollowingTask.CreatedBy.Id); Assert.AreEqual(1, furtherControlMeasureTask.FollowingTask.Documents.Count); Assert.AreEqual(furtherControlMeasureTask.Documents[0].DocumentLibraryId, furtherControlMeasureTask.FollowingTask.Documents[0].DocumentLibraryId); Assert.AreEqual(furtherControlMeasureTask.Documents[0].Description, furtherControlMeasureTask.FollowingTask.Documents[0].Description); Assert.AreEqual(furtherControlMeasureTask.Documents[0].DocumentType.Id, furtherControlMeasureTask.FollowingTask.Documents[0].DocumentType.Id); Assert.AreEqual(furtherControlMeasureTask.Documents[0].Filename, furtherControlMeasureTask.FollowingTask.Documents[0].Filename); Assert.AreEqual(furtherControlMeasureTask.Category.Id, furtherControlMeasureTask.FollowingTask.Category.Id); Assert.AreEqual(furtherControlMeasureTask.TaskReoccurringType, furtherControlMeasureTask.FollowingTask.TaskReoccurringType); Assert.AreEqual(furtherControlMeasureTask.TaskReoccurringEndDate, furtherControlMeasureTask.FollowingTask.TaskReoccurringEndDate); }
private bool SendToWork(Building build, Employee emplo) { if (emplo == null) return false; EmployeeManager.Share(emplo, build.Employees); return true; }
public void StartUp() { // add prices to the dictionary, prices prices.Add("Dog", 120); prices.Add("Cat", 60); prices.Add("Snake", 40); prices.Add("Guinea pig", 20); prices.Add("Canary", 15); // create customers Customer c1 = new Customer(1001, "Susan", "Peterson", "Borgergade 45", "8000", "Aarhus", "*****@*****.**", "211a212121"); Customer c2 = new Customer(1002, "Brian", "Smith", "Allegade 108", "8000", "Aarhus", "*****@*****.**", "45454545"); //opret Employees Employee e1 = new Employee("Gitte", "Svendsen", "GIT", "234234234"); Employee e2 = new Employee("Mads", "Juul", "MUL", "911112112"); Pet p1 = new Pet("Dog", "Hamlet", new DateTime(2011, 9, 2), new DateTime(2011,9,20), c1, e1); Pet p2 = new Pet("Dog", "Samson", new DateTime(2011, 9, 14), new DateTime(2011, 9, 21), c1, e1); Pet p3 = new Pet("Cat", "Darla", new DateTime(2011, 9, 7), new DateTime(2011, 9, 10), c2, e2); // add Pets to list of Pet, pets pets.Add(p1); pets.Add(p2); pets.Add(p3); // add customers to list customer.Add(c1); customer.Add(c2); }
private void testArray() { Int32[] myIntegers; // Объявление ссылки на массив, myIntegers = null myIntegers = new Int32[100]; // Создание массива типа Int32 из 100 элементов, равных 0 Employee[] myEmployees; // Объявление ссылки на массивб myEmployees = null myEmployees = new Employee[50]; // Создание массива из 50 ссылок на переменную Control, равных null // Создание двухмерного массива типа Doubles Double[,] myDoubles = new Double[10, 20]; // Создание трехмерного массива ссылок на строки String[,,] myStrings = new String[5, 3, 10]; // Создание одномерного массива из массивов типа Point Point[][] myPolygons = new Point[3][]; // myPolygons[0] ссылается на массив из 10 экземпляров типа Point myPolygons[0] = new Point[10]; // myPolygons[1] ссылается на массив из 20 экземпляров типа Point myPolygons[1] = new Point[20]; // myPolygons[2] ссылается на массив из 30 экземпляров типа Point myPolygons[2] = new Point[30]; // вывод точек первого многоугольника // for (Int32 x = 0; x < myPolygons[0].Length; x++) // Console.WriteLine(myPolygons[0][x]); }
public EmployeeView(Employee input) { Mapper.CreateMap<Employee, EmployeeView>(); Mapper.Map<Employee, EmployeeView>(input, this); this.updated = input.updated.ToString().Replace('T', ' '); }
static void Main() { Dictionary<string, int> positions = new Dictionary<string, int>(); List<Employee> personnel = new List<Employee>(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string[] input = Console.ReadLine().Split('-'); if(!positions.ContainsKey(input[0].Trim())) { positions.Add(input[0].Trim(), int.Parse(input[1])); } } int m = int.Parse(Console.ReadLine()); for (int i = 0; i < m; i++) { string[] input = Console.ReadLine().Split('-'); Employee single = new Employee(); string[] name = input[0].Trim().Split(' '); single.firstName = name[0]; single.lastName = name[1]; int positionValue; positions.TryGetValue(input[1].Trim(), out positionValue); single.value = positionValue; personnel.Add(single); } foreach (Employee person in personnel.OrderByDescending(p => p.value).ThenBy(p => p.lastName).ThenBy(p => p.firstName)) { Console.WriteLine("{0} {1}", person.firstName, person.lastName); } }
public static int AddEmployee(Employee data) { return EmployeeDB.Add(data); }
public static void Initialize(TensunContext context) { context.Database.EnsureCreated(); if (context.Products.Any()) { return; } var products = new Product[] { new Product { ProductCatalog = ProductCatalog.A类产品, ProductName = "产品AAA", ProductModel = "TSF-9200", ProductParameter = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. ", ProductDesc = "可以产生 10 种不同语言(或称为语言风格)的范例文字,并能设定产生字数、字符数或段落数,在进阶选项里,还能针对文字字型、粗细、文字距离、对齐方式来产生 CSS 程序代码。" }, new Product { ProductCatalog = ProductCatalog.B类产品, ProductName = "产品BBB", ProductModel = "GS9208", ProductParameter = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. ", ProductDesc = "可以产生 10 种不同语言(或称为语言风格)的范例文字,并能设定产生字数、字符数或段落数,在进阶选项里,还能针对文字字型、粗细、文字距离、对齐方式来产生 CSS 程序代码。" }, new Product { ProductCatalog = ProductCatalog.C类产品, ProductName = "产品CCC", ProductModel = "TS-VID612S", ProductParameter = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. ", ProductDesc = "可以产生 10 种不同语言(或称为语言风格)的范例文字,并能设定产生字数、字符数或段落数,在进阶选项里,还能针对文字字型、粗细、文字距离、对齐方式来产生 CSS 程序代码。" } }; foreach (Product p in products) { context.Products.Add(p); } context.SaveChanges(); var projects = new Project[] { new Project { ProjectName = "陕西ABCD项目", ProjectType = ProjectType.系统集成, Province = Province.陕西省, Region = TSRegion.西区, StartDate = DateTime.Parse("2017/3/1"), DeliveryDate = DateTime.Parse("2017/9/1"), Status = ProjectStatus.进行中 }, new Project { ProjectName = "汉中EFG项目", ProjectType = ProjectType.系统集成, Province = Province.陕西省, Region = TSRegion.西区, StartDate = DateTime.Parse("2017/2/1"), DeliveryDate = DateTime.Parse("2017/6/1"), Status = ProjectStatus.进行中 }, new Project { ProjectName = "成都AAA项目", ProjectType = ProjectType.系统集成, Province = Province.四川省, Region = TSRegion.西南区, StartDate = DateTime.Parse("2016/3/1"), DeliveryDate = DateTime.Parse("2016/9/1"), Status = ProjectStatus.维保期 } }; foreach (Project p in projects) { context.Projects.Add(p); } context.SaveChanges(); var projectproducts = new ProjectProduct[] { new ProjectProduct { ProjectID = 1, ProductID = 1, Qty = 100 }, new ProjectProduct { ProjectID = 1, ProductID = 2, Qty = 120 }, new ProjectProduct { ProjectID = 1, ProductID = 3, Qty = 50 }, new ProjectProduct { ProjectID = 2, ProductID = 1, Qty = 50 }, new ProjectProduct { ProjectID = 2, ProductID = 2, Qty = 80 }, new ProjectProduct { ProjectID = 2, ProductID = 3, Qty = 60 }, new ProjectProduct { ProjectID = 3, ProductID = 2, Qty = 90 }, new ProjectProduct { ProjectID = 3, ProductID = 1, Qty = 85 } }; foreach (ProjectProduct pp in projectproducts) { context.ProjectProducts.Add(pp); } context.SaveChanges(); var employees = new Employee[] { new Employee { EmpName = "小张", Dept = TSDept.技术部, Title = TSTitle.部门经理 }, new Employee { EmpName = "小李", Dept = TSDept.技术部, Title = TSTitle.员工 }, new Employee { EmpName = "小王", Dept = TSDept.技术部, Title = TSTitle.部门经理 } }; foreach (Employee e in employees) { context.Employees.Add(e); } context.SaveChanges(); var projectteammembers = new ProjectTeamMember[] { new ProjectTeamMember { ProjectID = 1, EmployeeID = 1, TeamMemberType = TeamMemberType.项目经理 }, new ProjectTeamMember { ProjectID = 1, EmployeeID = 2, TeamMemberType = TeamMemberType.实施工程师 }, new ProjectTeamMember { ProjectID = 1, EmployeeID = 3, TeamMemberType = TeamMemberType.实施工程师 }, new ProjectTeamMember { ProjectID = 2, EmployeeID = 2, TeamMemberType = TeamMemberType.项目经理 }, new ProjectTeamMember { ProjectID = 2, EmployeeID = 3, TeamMemberType = TeamMemberType.实施工程师 }, new ProjectTeamMember { ProjectID = 3, EmployeeID = 1, TeamMemberType = TeamMemberType.项目经理 }, new ProjectTeamMember { ProjectID = 3, EmployeeID = 2, TeamMemberType = TeamMemberType.实施工程师 }, new ProjectTeamMember { ProjectID = 3, EmployeeID = 3, TeamMemberType = TeamMemberType.售前技术 } }; foreach (ProjectTeamMember pt in projectteammembers) { context.ProjectTeamMembers.Add(pt); } context.SaveChanges(); }
public (int salary, int bonus) GetCompensation(Employee employee) => (CalculateSalary(employee), CalculateBonus(employee));
public bool Update(Employee entity) { Set.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; return(SaveChanges() > 0); }
public bool Delete(Employee entity) { Set.Remove(entity); return(SaveChanges() > 0); }
public Employee Add(Employee e) { return(Set.Add(e)); }
/// <summary> /// Cập nhật nhân viên /// </summary> /// <param name="employeeID"></param> /// <param name="data"></param> /// <returns></returns> public static bool UpdateEmployee(int employeeID, Employee data) { return EmployeeDB.Update(employeeID, data); }
private void btnExportToExcel_Click(object sender, RoutedEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "excel文件|*.xls"; if (sfd.ShowDialog() != true) { return; } string fileName = sfd.FileName; HSSFWorkbook workbook = new HSSFWorkbook(); ISheet sheet = workbook.CreateSheet("员工信息表"); IRow rowHeader = sheet.CreateRow(0); rowHeader.CreateCell(0, CellType.STRING).SetCellValue("姓名"); rowHeader.CreateCell(1, CellType.STRING).SetCellValue("工号"); rowHeader.CreateCell(2, CellType.STRING).SetCellValue("入职时间"); rowHeader.CreateCell(3, CellType.STRING).SetCellValue("学历"); rowHeader.CreateCell(4, CellType.STRING).SetCellValue("毕业院校"); rowHeader.CreateCell(5, CellType.STRING).SetCellValue("基本工资"); rowHeader.CreateCell(6, CellType.STRING).SetCellValue("部门"); rowHeader.CreateCell(7, CellType.STRING).SetCellValue("职位"); rowHeader.CreateCell(8, CellType.STRING).SetCellValue("合同签订日期"); rowHeader.CreateCell(9, CellType.STRING).SetCellValue("合同到期日期"); Employee[] employees = (Employee[])datagrid.ItemsSource; ICellStyle cellStyle = workbook.CreateCellStyle(); IDataFormat dataFormat = workbook.CreateDataFormat(); cellStyle.DataFormat = dataFormat.GetFormat("yyyy\"年\"m\"月\"d\"日\""); for (int i = 0; i < employees.Length; i++) { Employee employee = employees[i]; IRow row = sheet.CreateRow(i + 1); row.CreateCell(0, CellType.STRING).SetCellValue(employee.Name); row.CreateCell(1, CellType.STRING).SetCellValue(employee.Number); ICell dateCell = row.CreateCell(2, CellType.NUMERIC); dateCell.CellStyle = cellStyle; dateCell.SetCellValue(employee.InDate); row.CreateCell(3, CellType.STRING).SetCellValue(IdNameDAL.GetEducationNameById(employee.EducationId)); row.CreateCell(4, CellType.STRING).SetCellValue(employee.School); row.CreateCell(5, CellType.STRING).SetCellValue(employee.BaseSalary); row.CreateCell(6, CellType.STRING).SetCellValue(DepartmentDAL.GetById(employee.DepartmentId).Name); row.CreateCell(7, CellType.STRING).SetCellValue(employee.Position); ICell contractBegindateCell = row.CreateCell(8, CellType.NUMERIC); contractBegindateCell.CellStyle = cellStyle; contractBegindateCell.SetCellValue(employee.ContractStartDay); ICell contractEnddateCell = row.CreateCell(9, CellType.NUMERIC); contractEnddateCell.CellStyle = cellStyle; contractEnddateCell.SetCellValue(employee.ContractEndDay); } using (Stream stream = File.OpenWrite(fileName)) { workbook.Write(stream); } }
public void Insert(Employee employee) { employee.Id = new Guid(); employee.Dependents.ForEach(d => d.Id = new Guid()); Employees.Add(employee.Id.Value, employee); }
public ActionResult NewEmployee(Employee employeeNew) { employee.NewEmployee(employeeNew); return(RedirectToAction("Index")); }
public bool DeleteUser(User user) { try { //delete user from the database using (MySqlConnection connection = new MySqlConnection(App.masterConnectionString)) { connection.Open(); MySqlCommand deleteCommand = connection.CreateCommand(); MySqlCommand getCommand = connection.CreateCommand(); bool exists; //delete user based on type of user if (user is Customer) { deleteCommand.CommandText = @"DELETE FROM customer WHERE user_id = @userID"; deleteCommand.Parameters.AddWithValue("@userID", user.UserID); deleteCommand.ExecuteNonQuery(); deleteCommand.CommandText = @"DELETE FROM user WHERE user_id = @userID"; deleteCommand.ExecuteNonQuery(); } else if (user is Employee) { Employee employee = (Employee)user; getCommand.CommandText = @"SELECT * FROM sale WHERE saleby = @userID"; getCommand.Parameters.AddWithValue("@userID", user.UserID); //if employee has made a sale using (MySqlDataReader reader = getCommand.ExecuteReader()) { if (reader.Read()) { exists = true; } else { exists = false; } } //update employee's employed attribute if (exists == true) { deleteCommand.CommandText = @"UPDATE user SET employed = @employed WHERE user_id = @userID"; deleteCommand.Parameters.AddWithValue("@employed", employee.IsEmployed); deleteCommand.Parameters.AddWithValue("@userID", employee.UserID); deleteCommand.ExecuteNonQuery(); } else { //remove employee from database deleteCommand.CommandText = @"DELETE FROM employee WHERE user_id = @userID"; deleteCommand.Parameters.AddWithValue("@userID", employee.UserID); deleteCommand.ExecuteNonQuery(); deleteCommand.CommandText = @"DELETE FROM user WHERE user_id = @userID"; deleteCommand.ExecuteNonQuery(); } } return(true); } } catch (MySqlException) { Debug.WriteLine("Could not remove user"); return(false); } }
public void Update(Employee employee) { Employees[employee.Id.Value] = employee; }
private int GetPetNumberByEmployee(Employee employee) { return(_context.Pets.Where(p => p.EmployeeId == employee.EmployeeId).Count()); }
public Employee CreateEmployee(Employee emp) { var response = _client.PostAsJsonAsync <Employee>($"api/user/reg", emp).Result; return(ResponseParse <Employee>(response)); }
public static Employee GetEmployeeDetails(string page, Employee employee) { page = page.Replace("\n", string.Empty); var employeeDetailsMatch = Regex.Match(page, @"<tr><th>pokój<\/th><td>(.*?)<\/td><\/tr>(.*?)<h3>Konsultacje:<\/h3><p>(.*?)<\/p>(.*?)<div class=""byWeekDays"">(.*?)<\/div>", RegexOptions.Multiline); if (employeeDetailsMatch == null) { throw new Exception(); } employee.Room = new Xamarin.Forms.FormattedString(); employee.Room.Spans.Add(new Xamarin.Forms.Span() { Text = "Pokój: ", FontAttributes = Xamarin.Forms.FontAttributes.Bold }); employee.Room.Spans.Add(new Xamarin.Forms.Span() { Text = employeeDetailsMatch.Groups[1].ToString().Trim(' ').Replace("\t", string.Empty) }); var consults = employeeDetailsMatch.Groups[3].ToString().Trim(' ').Replace("\t", string.Empty); if (consults.Length > 0) { employee.Consults = consults.ToUpper()[0] + consults.Substring(1); } else { employee.Consults = "Brak danych"; } var weekByDays = employeeDetailsMatch.Groups[5].ToString(); var daysMatch = Regex.Matches(weekByDays, @"<h3>(.*?)<\/h3><ul>(.*?)<\/ul>"); var dict = new List <GenericGroupedCollection <string, string> >(); foreach (Match match in daysMatch) { var day = match.Groups[1].ToString(); if (day == "Poniedzialek") { day = "Poniedziałek"; } if (day == "Sroda") { day = "Środa"; } if (day == "Piatek") { day = "Piątek"; } var x = new GenericGroupedCollection <string, string>(day); var classesMatch = Regex.Matches(match.Groups[2].ToString(), @"<li><span class=""time"">(.*?)</span><span class=""name"">(.*?)</span><span class=""type"">(.*?)</span><span class=""classroom"">(.*?)</span></li>", RegexOptions.Multiline); foreach (Match classMatch in classesMatch) { var hours = classMatch.Groups[1].ToString().Trim(' ').Replace("\t", string.Empty); var name = classMatch.Groups[2].ToString().Trim(' ').Replace("\t", string.Empty); var type = classMatch.Groups[3].ToString().Trim(' ').Replace("\t", string.Empty).Replace("–", string.Empty); if (type.Length == 0) { type = "Brak danych"; } var classRoom = classMatch.Groups[4].ToString().Trim(' ').Replace("\t", string.Empty); x.Add(string.Format("{0} {1}, {2} s.{3}", hours, name, type, classRoom)); } dict.Add(x); } employee.WeekPlan = dict; return(employee); }
public bool AddNewUser(User newUser) { try { //add new user to the database using (MySqlConnection connection = new MySqlConnection(App.masterConnectionString)) { connection.Open(); MySqlCommand insertCommand1 = connection.CreateCommand(); MySqlCommand insertCommand2 = connection.CreateCommand(); insertCommand1.CommandText = @"INSERT INTO user (user_id, firstname, lastname, user_type) VALUES (@id, @first_name, @last_name, @type)"; insertCommand1.Parameters.AddWithValue("@id", newUser.UserID); insertCommand1.Parameters.AddWithValue("@first_name", newUser.FirstName); insertCommand1.Parameters.AddWithValue("@last_name", newUser.LastName); insertCommand1.Parameters.AddWithValue("@type", newUser.UserType); insertCommand1.ExecuteNonQuery(); //add user based on type of user if (newUser is Employee) { Employee newEmployee = (Employee)newUser; insertCommand2.CommandText = @"INSERT INTO employee (user_id, isManager, password, employed) VALUES (@id, @isManager, @password, @employed)"; insertCommand2.Parameters.AddWithValue("@id", newEmployee.UserID); insertCommand2.Parameters.AddWithValue("@isManager", newEmployee.IsManager); insertCommand2.Parameters.AddWithValue("@password", newEmployee.Password); insertCommand2.Parameters.AddWithValue("@employed", newEmployee.IsEmployed); } else if (newUser is Customer) { Customer newCustomer = (Customer)newUser; insertCommand2.CommandText = @"INSERT INTO customer (user_id, email, phone) VALUES (@id, @email, @phone)"; insertCommand2.Parameters.AddWithValue("@id", newCustomer.UserID); insertCommand2.Parameters.AddWithValue("@email", newCustomer.Email); insertCommand2.Parameters.AddWithValue("@phone", newCustomer.Phone); } insertCommand2.ExecuteNonQuery(); return(true); } } catch (MySqlException) { Debug.WriteLine("Could not add user"); return(false); } }
public void saveEmployee(Employee mo) { base.save(mo); }
protected void Page_PreInit(object sender, EventArgs e) { curAdmin = AdminUtils.GetEmployeeFromSessionOrLogOut(); }
public override void load(IModelObject mo) { const int DATAREADER_FLD_EMPLOYEEID = 0; const int DATAREADER_FLD_EMPLOYEENAME = 1; const int DATAREADER_FLD_EMPLOYEERANKID = 2; const int DATAREADER_FLD_SALARY = 3; const int DATAREADER_FLD_ADDRESS = 4; const int DATAREADER_FLD_TELEPHONE = 5; const int DATAREADER_FLD_MOBILE = 6; const int DATAREADER_FLD_IDNUMBER = 7; const int DATAREADER_FLD_SSINUMBER = 8; const int DATAREADER_FLD_HIREDATE = 9; const int DATAREADER_FLD_NUMDEPENDENTS = 10; const int DATAREADER_FLD_EMPLOYEETYPECODE = 11; const int DATAREADER_FLD_CREATEDATE = 12; const int DATAREADER_FLD_UPDATEDATE = 13; const int DATAREADER_FLD_CREATEUSER = 14; const int DATAREADER_FLD_UPDATEUSER = 15; const int DATAREADER_FLD_SAMPLEGUIDFIELD = 16; const int DATAREADER_FLD_ISACTIVE = 17; const int DATAREADER_FLD_SAMPLEBIGINT = 18; const int DATAREADER_FLD_SAMPLESMALLINT = 19; const int DATAREADER_FLD_SAMPLENUMERICFIELDINT = 20; const int DATAREADER_FLD_SAMPLENUMERICFIELD2DECIMALS = 21; const int DATAREADER_FLD_EMPLOYEETYPEDESCR = 22; const int DATAREADER_FLD_RANKDESCR = 23; Employee obj = (Employee)mo; obj.IsObjectLoading = true; if (!this.reader.IsDBNull(DATAREADER_FLD_EMPLOYEEID)) { obj.PrEmployeeId = Convert.ToInt64(this.reader.GetInt32(DATAREADER_FLD_EMPLOYEEID)); } if (!this.reader.IsDBNull(DATAREADER_FLD_EMPLOYEENAME)) { obj.PrEmployeeName = this.reader.GetString(DATAREADER_FLD_EMPLOYEENAME); } if (!this.reader.IsDBNull(DATAREADER_FLD_EMPLOYEERANKID)) { obj.PrEmployeeRankId = Convert.ToInt64(this.reader.GetInt32(DATAREADER_FLD_EMPLOYEERANKID)); } if (!this.reader.IsDBNull(DATAREADER_FLD_SALARY)) { obj.PrSalary = this.reader.GetDecimal(DATAREADER_FLD_SALARY); } if (!this.reader.IsDBNull(DATAREADER_FLD_ADDRESS)) { obj.PrAddress = this.reader.GetString(DATAREADER_FLD_ADDRESS); } if (!this.reader.IsDBNull(DATAREADER_FLD_TELEPHONE)) { obj.PrTelephone = this.reader.GetString(DATAREADER_FLD_TELEPHONE); } if (!this.reader.IsDBNull(DATAREADER_FLD_MOBILE)) { obj.PrMobile = this.reader.GetString(DATAREADER_FLD_MOBILE); } if (!this.reader.IsDBNull(DATAREADER_FLD_IDNUMBER)) { obj.PrIdNumber = this.reader.GetString(DATAREADER_FLD_IDNUMBER); } if (!this.reader.IsDBNull(DATAREADER_FLD_SSINUMBER)) { obj.PrSSINumber = this.reader.GetString(DATAREADER_FLD_SSINUMBER); } if (!this.reader.IsDBNull(DATAREADER_FLD_HIREDATE)) { obj.PrHireDate = this.reader.GetDateTime(DATAREADER_FLD_HIREDATE); } if (!this.reader.IsDBNull(DATAREADER_FLD_NUMDEPENDENTS)) { obj.PrNumDependents = Convert.ToInt64(this.reader.GetInt32(DATAREADER_FLD_NUMDEPENDENTS)); } if (!this.reader.IsDBNull(DATAREADER_FLD_EMPLOYEETYPECODE)) { obj.PrEmployeeTypeCode = this.reader.GetString(DATAREADER_FLD_EMPLOYEETYPECODE); } if (!this.reader.IsDBNull(DATAREADER_FLD_CREATEDATE)) { obj.CreateDate = this.reader.GetDateTime(DATAREADER_FLD_CREATEDATE); } if (!this.reader.IsDBNull(DATAREADER_FLD_UPDATEDATE)) { obj.UpdateDate = this.reader.GetDateTime(DATAREADER_FLD_UPDATEDATE); } if (!this.reader.IsDBNull(DATAREADER_FLD_CREATEUSER)) { obj.CreateUser = this.reader.GetString(DATAREADER_FLD_CREATEUSER); } if (!this.reader.IsDBNull(DATAREADER_FLD_UPDATEUSER)) { obj.UpdateUser = this.reader.GetString(DATAREADER_FLD_UPDATEUSER); } if (!this.reader.IsDBNull(DATAREADER_FLD_SAMPLEGUIDFIELD)) { obj.PrSampleGuidField = this.reader.GetGuid(DATAREADER_FLD_SAMPLEGUIDFIELD); } if (!this.reader.IsDBNull(DATAREADER_FLD_ISACTIVE)) { obj.PrIsActive = this.reader.GetBoolean(DATAREADER_FLD_ISACTIVE); } if (!this.reader.IsDBNull(DATAREADER_FLD_SAMPLEBIGINT)) { obj.PrSampleBigInt = this.reader.GetInt64(DATAREADER_FLD_SAMPLEBIGINT); } if (!this.reader.IsDBNull(DATAREADER_FLD_SAMPLESMALLINT)) { obj.PrSampleSmallInt = Convert.ToInt64(this.reader.GetInt16(DATAREADER_FLD_SAMPLESMALLINT)); } if (!this.reader.IsDBNull(DATAREADER_FLD_SAMPLENUMERICFIELDINT)) { obj.PrSampleNumericFieldInt = Convert.ToInt64(this.reader.GetDecimal(DATAREADER_FLD_SAMPLENUMERICFIELDINT)); } if (!this.reader.IsDBNull(DATAREADER_FLD_SAMPLENUMERICFIELD2DECIMALS)) { obj.PrSampleNumericField2Decimals = this.reader.GetDecimal(DATAREADER_FLD_SAMPLENUMERICFIELD2DECIMALS); } if (!this.reader.IsDBNull(DATAREADER_FLD_EMPLOYEETYPEDESCR)) { obj.PrEmployeeTypeDescr = this.reader.GetString(DATAREADER_FLD_EMPLOYEETYPEDESCR); } if (!this.reader.IsDBNull(DATAREADER_FLD_RANKDESCR)) { obj.PrRankDescr = this.reader.GetString(DATAREADER_FLD_RANKDESCR); } obj.isNew = false; // since we've just loaded from database, we mark as "old" obj.isDirty = false; obj.IsObjectLoading = false; obj.afterLoad(); return; }
public List <Employee> LoadEmployeeData(string EmployeeId) { DataTable dt = null; List <Employee> lstemployee = null; using (SqlConnection con = new SqlConnection(Convert.ToString(ConfigurationManager.AppSettings["DBConnectionstring"]))) { using (SqlCommand cmd = new SqlCommand()) { try { dt = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "SP_LoadEmployee", new SqlParameter("@EmployeeId", EmployeeId)).Tables[0]; lstemployee = new List <Employee>(); Employee clsemployee = new Employee(); clsemployee.employeeusername = dt.Rows[0]["empid"].ToString(); clsemployee.FirstName = dt.Rows[0]["firstname"].ToString(); clsemployee.MiddleName = dt.Rows[0]["lastname"].ToString(); clsemployee.LastName = dt.Rows[0]["lastname"].ToString(); clsemployee.Address = dt.Rows[0]["address"].ToString(); clsemployee.City = dt.Rows[0]["city"].ToString(); clsemployee.State = dt.Rows[0]["StateName"].ToString(); clsemployee.Zip = dt.Rows[0]["Zip"].ToString(); clsemployee.HomePhone = dt.Rows[0]["homephone"].ToString(); clsemployee.CellPhone = dt.Rows[0]["cellphone"].ToString(); clsemployee.CellPhoneCarrierId = dt.Rows[0]["cellphonecarrierid"].ToString(); clsemployee.EmailAddress = dt.Rows[0]["emailaddress"].ToString(); clsemployee.SystemRoleId = Convert.ToInt32(dt.Rows[0]["systemroleid"]); clsemployee.BirthDate = Convert.ToDateTime(dt.Rows[0]["birthdate"]); if (string.IsNullOrEmpty(dt.Rows[0]["hiredate"].ToString())) { clsemployee.GetHireDate = null; } else { clsemployee.HireDate = Convert.ToDateTime(dt.Rows[0]["hiredate"]); clsemployee.GetHireDate = clsemployee.HireDate.ToString(); } clsemployee.MaritalStatus = dt.Rows[0]["maritalstatus"].ToString(); if (string.IsNullOrEmpty(dt.Rows[0]["numberofdependents"].ToString())) { clsemployee.NumberOfDependents = 0; } else { clsemployee.NumberOfDependents = Convert.ToInt32(dt.Rows[0]["numberofdependents"]); } clsemployee.Insurance = dt.Rows[0]["insurance"].ToString(); if (string.IsNullOrEmpty(dt.Rows[0]["insurancedate"].ToString())) { clsemployee.GetInsuranceDate = null; } else { clsemployee.InsuranceDate = Convert.ToDateTime(dt.Rows[0]["insurancedate"]); clsemployee.GetHireDate = clsemployee.GetInsuranceDate.ToString(); } clsemployee.AdditionalWithHoldings = dt.Rows[0]["additionalwitholdings"].ToString(); clsemployee.DriverEligible = dt.Rows[0]["drivereligible"].ToString(); clsemployee.DriverStatus = dt.Rows[0]["driverstatus"].ToString(); clsemployee.IsActive = Convert.ToBoolean(dt.Rows[0]["isactive"]); clsemployee.StoreId = dt.Rows[0]["storeid"].ToString(); clsemployee.SocialSecurityNumber = (!string.IsNullOrEmpty(dt.Rows[0]["SocialSecurityNumber"].ToString())) ? Convert.ToInt32(dt.Rows[0]["SocialSecurityNumber"]): 0; clsemployee.EmployeeLoginId = (!string.IsNullOrEmpty(dt.Rows[0]["EmployeeID"].ToString())) ? Convert.ToInt32(dt.Rows[0]["EmployeeID"]) : 0; lstemployee.Add(clsemployee); } catch (Exception ex) { ex.ToString(); } } } return(lstemployee); }
public void Update(Employee employee) { Put(Address, employee); }
public static void deleteEmployee(Employee EmployeeObj) { EmployeeDBMapper dbm = new EmployeeDBMapper(); dbm.delete(EmployeeObj); }
// // GET: /Projects/Edit/5 public ActionResult Edit(int id) { ViewBag.employees = new SelectList(Employee.FindAll(), "EmpID", "FullName"); ViewBag.departments = new SelectList(Department.FindAll(), "DeptID", "DeptName"); return(View(Project.FindById(id))); }
public void AddEmployee(Employee employee) { list.Add(employee); }
public IActionResult Details(int id) { Employee employee = Employees.FirstOrDefault(x => x.ID == id); return(View(employee)); }
public bool Update(Employee employee) { _context.Entry <Employee>(employee).State = EntityState.Modified; return(_context.SaveChanges() > 0); }
public override void Execute() { Console.WriteLine("Executing Example: " + this.Title); Console.WriteLine("See: " + Settings.Default.DeveloperPortalBaseUrl + this.DocsUrl); Console.WriteLine("==================================="); // Step 1: Create an Employer Console.WriteLine("Step 1: Create an Employer"); var employer = new Employer { EffectiveDate = new DateTime(2020, 8, 1), Name = "Getting Started Co Ltd", BacsServiceUserNumber = "123456", RuleExclusions = RuleExclusionFlags.None, Territory = CalculatorTerritory.UnitedKingdom, Region = CalculatorRegion.England, Address = new Address { Address1 = "House", Address2 = "Street", Address3 = "Town", Address4 = "County", Postcode = "TE1 1ST", Country = "United Kingdom" }, HmrcSettings = new HmrcSettings { TaxOfficeNumber = "451", TaxOfficeReference = "A451", AccountingOfficeRef = "123PA1234567X", Sender = Sender.Employer, SenderId = "ISV451", Password = "******", ContactFirstName = "Joe", ContactLastName = "Bloggs", ContactEmail = "*****@*****.**", ContactTelephone = "01234567890", ContactFax = "01234567890" }, BankAccount = new BankAccount { AccountName = "Getting St", AccountNumber = "12345678", SortCode = "012345" } }; var employerLink = this.ApiHelper.Post("/Employers", employer); Console.WriteLine($" CREATED: {employerLink.Title} - {employerLink.Href}"); // Step 2: Create a Pay Schedule Console.WriteLine("Step 2: Create a Pay Schedule"); var paySchedule = new PaySchedule { Name = "My Weekly", PayFrequency = PayFrequency.Weekly }; var payScheduleLink = this.ApiHelper.Post(employerLink.Href + "/PaySchedules", paySchedule); Console.WriteLine($" CREATED: {payScheduleLink.Title} - {payScheduleLink.Href}"); // Step 3: Create an Employee Console.WriteLine("Step 3: Create an Employee"); var employee = new Employee { EffectiveDate = new DateTime(2020, 8, 1), Code = "EMP001", Title = "Mr", FirstName = "Terry", MiddleName = "T", LastName = "Tester", Initials = "TTT", NiNumber = "AA000000A", DateOfBirth = new DateTime(1980, 1, 1), Gender = Gender.Male, NicLiability = NicLiability.IsFullyLiable, Region = CalculatorRegion.England, Territory = CalculatorTerritory.UnitedKingdom, PaySchedule = payScheduleLink, StartDate = new DateTime(2020, 8, 1), StarterDeclaration = StarterDeclaration.A, RuleExclusions = RuleExclusionFlags.None, WorkingWeek = WorkingWeek.AllWeekDays, Address = new Address { Address1 = "House", Address2 = "Street", Address3 = "Town", Address4 = "County", Postcode = "TE1 1ST", Country = "United Kingdom" }, HoursPerWeek = 40, PassportNumber = "123457890" }; var employeeLink = this.ApiHelper.Post(employerLink.Href + "/Employees", employee); Console.WriteLine($" CREATED: {employeeLink.Title} - {employeeLink.Href}"); // Step 4: Create a Pay Instruction (Salary) Console.WriteLine("Step 4: Create a Pay Instruction (Salary)"); var salaryInstruction = new SalaryPayInstruction { StartDate = new DateTime(2020, 8, 1), AnnualSalary = 25000.00m }; var salaryInstructionLink = this.ApiHelper.Post(employeeLink.Href + "/PayInstructions", salaryInstruction); Console.WriteLine($" CREATED: {salaryInstructionLink.Title} - {salaryInstructionLink.Href}"); // Step 5: Create a Pay Instruction (Salary) Console.WriteLine("Step 5: Create a Tax Instruction (1185L)"); var taxInstruction = new TaxPayInstruction { StartDate = new DateTime(2020, 8, 1), TaxCode = "1185L" }; var taxInstructionLink = this.ApiHelper.Post(employeeLink.Href + "/PayInstructions", taxInstruction); Console.WriteLine($" CREATED: {taxInstructionLink.Title} - {taxInstructionLink.Href}"); // Step 6: Create a Pay Run Job Console.WriteLine("Step 6: Create a Pay Run Job"); var payRunJob = new PayRunJobInstruction { PaymentDate = new DateTime(2020, 8, 17), StartDate = new DateTime(2020, 8, 13), EndDate = new DateTime(2020, 8, 19), PaySchedule = payScheduleLink }; var jobInfoLink = this.ApiHelper.Post("/Jobs/Payruns", payRunJob); Console.WriteLine($" CREATED: {jobInfoLink.Title} - {jobInfoLink.Href}"); // Step 7: Query Pay Run Job Status Console.WriteLine("Step 7: Query Pay Run Job Status"); this.PollPayRunJobStatus(jobInfoLink); // Step 8: Create 2nd Pay Run Job Console.WriteLine("Step 8: Create a 2nd Pay Run Job"); var payRunJob2 = new PayRunJobInstruction { PaymentDate = new DateTime(2020, 8, 24), StartDate = new DateTime(2020, 8, 20), EndDate = new DateTime(2020, 8, 26), PaySchedule = payScheduleLink }; var jobInfoLink2 = this.ApiHelper.Post("/Jobs/Payruns", payRunJob2); Console.WriteLine($" CREATED: {jobInfoLink2.Title} - {jobInfoLink2.Href}"); // Step 9: Query Pay Run Job Status Console.WriteLine("Step 9: Query Pay Run Job Status"); this.PollPayRunJobStatus(jobInfoLink2); // Step 10: Query Pay Run Job Status Console.WriteLine("Step 10: Recieve late notification of employee tax code change, requires retrospective correction."); var newTaxInstruction = new TaxPayInstruction { StartDate = new DateTime(2020, 8, 20), TaxCode = "1285L" }; // Step 11: Get all payruns for employee Console.WriteLine("Step 11: Get all PayRuns for Employee"); var payruns = this.ApiHelper.GetLinks(employeeLink.Href + "/PayRuns"); foreach (var link in payruns.Links) { Console.WriteLine($" -- {link.Title} ({link.Href})"); } // Step 12: Loop Employee PayRuns and DELETE any with payment date after new tax code effective date. Console.WriteLine("Step 12: Loop Employee PayRuns and DELETE any with payment date after new tax code effective date."); Console.WriteLine($"New tax code effective date: {newTaxInstruction.StartDate:yyyy-MM-dd}"); foreach (var link in payruns.Links) { var payrun = this.ApiHelper.Get <PayRun>(link.Href); if (payrun.PaymentDate >= newTaxInstruction.StartDate) { this.ApiHelper.Delete(link.Href); Console.WriteLine($" -- DELETE {link.Title} ({link.Href})"); } } // Step 13: End Existing Tax Instruction Console.WriteLine("Step 13: End Existing Tax Instruction"); taxInstruction.EndDate = newTaxInstruction.StartDate.AddDays(-1); taxInstruction = this.ApiHelper.Put <TaxPayInstruction>(taxInstructionLink.Href, taxInstruction); Console.WriteLine($" UPDATE: {jobInfoLink2.Title} successfully ended {taxInstruction.EndDate.GetValueOrDefault():yyyy-MM-dd}"); // Step 14: Create new Tax Instruction (1285L) Console.WriteLine("Step 14: Create new Tax Instruction (1285L)"); var newTaxInstructionLink = this.ApiHelper.Post(employeeLink.Href + "/PayInstructions", newTaxInstruction); Console.WriteLine($" CREATED: {newTaxInstructionLink.Title} - {newTaxInstructionLink.Href}"); // Step 15: Re-queue 2nd Payrun Job Console.WriteLine("Step 15: Re-queue 2nd Payrun Job"); var jobInfoLink3 = this.ApiHelper.Post("/Jobs/Payruns", payRunJob2); Console.WriteLine($" CREATED: {jobInfoLink3.Title} - {jobInfoLink3.Href}"); // Step 16: Query Pay Run Job Status Console.WriteLine("Step 16: Query Pay Run Job Status"); this.PollPayRunJobStatus(jobInfoLink3); // Step 17: Get the Employee Payslip Console.WriteLine("Step 17: Get the Employee Payslip"); var employerKey = employerLink.Href.Split('/').Last(); var payscheuleKey = payScheduleLink.Href.Split('/').Last(); var payslipReport = this.ApiHelper.GetRawXml($"/Report/PAYSLIP3/run?EmployerKey={employerKey}&PayScheduleKey={payscheuleKey}&TaxYear=2020&PaymentDate={payRunJob2.PaymentDate:yyyy-MM-dd}"); Console.WriteLine(payslipReport.InnerXml); // Step 18: Review Calculation Commentary Console.WriteLine("Step 18: Review Calculation Commentary"); var commentaryLinks = this.ApiHelper.GetLinks(employeeLink.Href + "/Commentaries"); var commentary = this.ApiHelper.Get <Commentary>(commentaryLinks.Links.Last().Href); Console.WriteLine(commentary.Detail); // End of example Console.WriteLine(string.Empty); Console.WriteLine("-- THE END --"); }
// // GET: /Projects/Create public ActionResult Create() { ViewBag.employees = new SelectList(Employee.FindAll(), "EmpID", "FullName"); ViewBag.departments = new SelectList(Department.FindAll(), "DeptID", "DeptName"); return(View()); }
public Employee Details(int id) { Employee employee = this.Context.Employees.Find(id); return(employee); }
public void CanCreateEmployeeWithDefaultConstructor() { var e = new Employee(); Assert.IsNotNull(e); }