public void Start() { var ceo = new Employee("Avinash", "CEO", 30000); var headSales = new Employee("Robert", "Head Sales", 20000); var headMarketing = new Employee("Michel", "Head Marketing", 20000); var clerkOne = new Employee("Laura", "Marketing", 10000); var clerkTwo = new Employee("Bob", "Marketing", 10000); var salesExecutiveOne = new Employee("Richard", "Sales", 10000); var salesExecutiveTwo = new Employee("Rob", "Sales", 10000); ceo.Add(headSales); ceo.Add(headMarketing); headSales.Add(salesExecutiveOne); headSales.Add(salesExecutiveTwo); headMarketing.Add(clerkOne); headMarketing.Add(clerkTwo); logger.Info($"CEO: {ceo}."); ceo.Employees.ForEach(x => { logger.Info(x); x.Employees.ForEach(e => { logger.Info(e); }); }); }
public void Main() { Employee CEO = new Employee("John", "CEO", 30000); Employee headSales = new Employee("Robert", "Head Sales", 20000); Employee headMarketing = new Employee("Michel", "Head Marketing", 20000); Employee clerk1 = new Employee("Laura", "Marketing", 10000); Employee clerk2 = new Employee("Bob", "Marketing", 10000); Employee salesExecutive1 = new Employee("Richard", "Sales", 10000); Employee salesExecutive2 = new Employee("Rob", "Sales", 10000); CEO.Add(headSales); CEO.Add(headMarketing); headSales.Add(salesExecutive1); headSales.Add(salesExecutive2); headMarketing.Add(clerk1); headMarketing.Add(clerk2); for (int i = 0; i < CEO.GetSubordinates().Count; i++) { for (int j = 0; j < CEO.GetSubordinates()[i].GetSubordinates().Count; j++) { Console.WriteLine(CEO.GetSubordinates()[i].GetSubordinates()[i].ToString()); } } }
static void Main08() { Folder folder1 = new Folder("folder1"); Component folder2 = new Folder("folder2"); folder1.GetContent(); folder2.GetContent(); File file1 = new File("file1"); Component file2 = new File("file2"); file1.GetContent(); file2.GetContent(); Console.ReadLine(); return; Employee CEO = new Employee("John", "CEO", 30000); Employee headSales = new Employee("Robert", "Head Sales", 20000); Employee headMarketing = new Employee("Michel", "Head Marketing", 20000); Employee clerk1 = new Employee("Laura", "Marketing", 10000); Employee clerk2 = new Employee("Bob", "Marketing", 10000); Employee salesExecutive1 = new Employee("Richard", "Sales", 10000); Employee salesExecutive2 = new Employee("Rob", "Sales", 10000); CEO.Add(headSales); CEO.Add(headMarketing); headSales.Add(salesExecutive1); headSales.Add(salesExecutive2); headMarketing.Add(clerk1); headMarketing.Add(clerk2); //打印该组织的所有员工 Console.WriteLine(CEO); foreach (Employee headEmployee in CEO.GetSubOrdinates()) { Console.WriteLine(headEmployee); foreach (Employee employee in headEmployee.GetSubOrdinates()) { Console.WriteLine(employee); } } Console.ReadLine(); }
static void Main(string[] args) { Employee objE = new Employee(); objE.Add(102, "John"); objE.Add(103, "James"); objE.Add(106, "Peter"); Console.WriteLine("Orignal values stored in Dictionary"); objE.GetDetails(); objE.OnRemove(106); }
public ActionResult Index(HttpPostedFileBase file) { try { string filepath = Path.GetTempFileName(); if (file.ContentLength > 0) { file.SaveAs(filepath); var employees = CSVParserLib.Parser.ParseEmployeesFromFile(filepath); System.IO.File.Delete(filepath); if (employees.Count() == 0) { ViewBag.Message = "Invalid file. File contains no data."; return(View()); } IEmployee employee = new Employee(); employee.DeleteAll(); var elist = employees.ToList(); elist.ForEach(e => employee.Add(e)); return(Redirect("/Employee/Index")); } ViewBag.Message = "Invalid file. File contains no data."; return(View()); } catch { ViewBag.Message = "Invalid file. Please select a csv file."; return(View()); } }
/// <summary> /// Add element into hashtable /// </summary> /// <param name="employee"></param> public static void Add(Employee employee) { while (true) { Console.WriteLine("Добавить элемент в хеш-таблицу?:\n1)Да\n2)Нет"); Console.Write("---> "); int choise = Convert.ToInt32(Console.ReadLine()); if (choise == 1) { Console.Write("Сколько добавить элементов: "); int num = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < num; i++) { Console.Write("Введите ключ: "); string key = Console.ReadLine(); Console.Write("Введите должность работника: "); string position = Console.ReadLine(); employee.Add(key, position); } } else if (choise == 2) { Console.Clear(); break; } else { Console.WriteLine("Неверное значение"); } } }
private void EmployeeInfo(string s) { try { Error.Text = string.Empty; var id = int.Parse(textBox1.Text.Trim()); var name = tName.Text.Trim(); var surname = tSurname.Text.Trim(); var email = tEmail.Text.Trim(); var password = tPassword.Text.Trim(); var address = tAddress.Text.Trim(); switch (s) { case "update": _employee.Update(id, name, surname, email, password, address); break; case "add": _employee.Add(name, surname, email, password, address); break; } dataGridView1.DataSource = _employee.Get("Employee"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_Add_Click(object sender, EventArgs e) { if (textBox_Name.Text == "") { MessageBox.Show("请输入员工姓名", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int vJobNo = 0; if (!int.TryParse(textBox_JobNo.Text, out vJobNo)) { MessageBox.Show("工号必须为数字", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string vOutInfo = ""; string vPhotoPath = pictureBox_Photo.Tag == null?"":(string)pictureBox_Photo.Tag; if (m_Employee.Add(textBox_Name.Text, comboBox_Sex.Text, vJobNo, textBox_CardNo.Text, vPhotoPath, comboBox_XingJi.Text, textBox_GeYan.Text, ref vOutInfo)) { MessageBox.Show("新增员工信息成功", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); dataGridView_EmployeeInfo.DataSource = m_Employee.GetAllEmplyees(); } else { MessageBox.Show(vOutInfo, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAdd_Click(object sender, EventArgs e) { // check match pass and confirm if (pwdPass.Text.Equals(pwdConfirm.Text)) { Employee em = new Employee(); em.setOpCode(txtEmpId.Text); em.setName(txtName.Text); em.setEmail(txtEmail.Text); em.setPwd(pwdPass.Text); em.setDept(txtDept.Text); if (em.Add()) { MessageBox.Show("Thành công. Mời đăng nhập!"); //change form this.Hide(); welcome wel = new welcome(); this.Hide(); wel.ShowDialog(); this.Close(); } else { MessageBox.Show("Nhân viên đã có tài khoản. Liên hệ phòng ME nếu quên mật khẩu"); this.Hide(); welcome w = new welcome(); w.ShowDialog(); this.Close(); } } else { MessageBox.Show("Mật khẩu và xác nhận không giống"); } }
static void Main(string[] args) { IOutput stringOutput = new StringOutput(); EmployeeComponent director = new Employee("Director", Program.POSITIONS[0], 20); EmployeeComponent manager = new Employee("Manager of storing", POSITIONS[1], 15); EmployeeComponent manager2 = new Employee("Manager of marketing", POSITIONS[1], 12); EmployeeComponent x = new SubEmployee("X", POSITIONS[2], 10); EmployeeComponent y = new SubEmployee("Y", POSITIONS[2], 10); EmployeeComponent a = new SubEmployee("A", POSITIONS[2], 10); EmployeeComponent b = new SubEmployee("B", POSITIONS[2], 10); EmployeeComponent c = new Employee("Another one manager", POSITIONS[1], 10); EmployeeComponent d = new SubEmployee("D", POSITIONS[2], 10); director.Add(manager, manager2); manager.Add(x, y, c); manager2.Add(a, b); c.Add(d); Company company = new Company(director, stringOutput); System.Console.WriteLine("----------"); company.PrintHierarchy(); System.Console.WriteLine("----------"); company.PrintAllByPosition("manager"); System.Console.WriteLine("----------"); company.PrintAllWithHighestSalaryAndHigherThan(9); System.Console.WriteLine("----------"); company.PrintAllWithParent(manager); System.Console.WriteLine("----------"); company.PrintBackwards(); System.Console.WriteLine("----------"); System.Console.ReadKey(); }
public string CreateEmployee(FormCollection FC) { Employee E = new Employee(); string File = FC["Attachment"]; if (File != " " && File != "") { if (FC["Ext"] == "png" || FC["Ext"] == "jpg" || FC["Ext"] == "jpeg" || FC["Ext"] == "gif") { Image Img = LoadImage(File); string Path; using (Bitmap image = new Bitmap(Img)) { //image object properties var fileName = Guid.NewGuid() + ".png"; Path = @"/content/Attachs/" + fileName; string ImagePath = Server.MapPath(Path); image.Save(ImagePath, ImageFormat.Png); } E.Attach = Path; } else { var fileName = Guid.NewGuid() + "." + FC["Ext"]; string PathO = @"/content/Attachs/" + fileName; string FilePath = Server.MapPath(PathO); byte[] filebytes = Convert.FromBase64String(File); FileStream fs = new FileStream(FilePath, FileMode.CreateNew, FileAccess.Write, FileShare.None); fs.Write(filebytes, 0, filebytes.Length); fs.Close(); E.Attach = PathO; } E.FileName = FC["FileName"]; } E.ExitDate = Convert.ToDateTime(FC["ExitDate"]); E.HoldingAssets = FC["HoldingAssets"]; E.ExitDeliveredAssets = FC["ExitDeliveredAssets"]; E.Notes = FC["Notes"]; E.InsurancePercentage = Convert.ToDouble(FC["InsurancePercentage"]); E.InsuranceFrom = Convert.ToDateTime(FC["InsuranceFrom"]); E.InsuranceTo = Convert.ToDateTime(FC["InsuranceTo"]); E.Address = FC["address"]; E.BasicSalary = Convert.ToInt32(FC["basicsalary"]); E.DateOfBirth = Convert.ToDateTime(FC["dateofbirth"]); E.HiringDate = Convert.ToDateTime(FC["hiringdate"]); E.Name = FC["name"]; E.Phone1 = FC["phone1"]; E.Phone2 = FC["phone2"]; E.SalaryType = Convert.ToInt32(FC["salarytype"]); E.SSN = FC["ssn"]; E.Title = FC["title"]; E.LastEditBy = (Session["User"] as User).ID; E.Add(); return("true"); }
private void EAdd_Click(object sender, EventArgs e) { Validation(); if (ESalary.Text != "" && EFname.Text != "" && ELname.Text != "" && EPhone.Text != "") { Employee em = new Employee(EFname.Text, ELname.Text, EBirth.Value, int.Parse(EPhone.Text), int.Parse(ESalary.Text), int.Parse(EMan.Text), empid); em.Add(); notifyIcon1.ShowBalloonTip(2000, "Welcome", "Emp Added", ToolTipIcon.Info); ShowItem(5, "Emp_db", this.emplst); } }
private void btnAdd_Click(object sender, EventArgs e) { newEmLoadDownd(); DialogResult dlg = MessageBox.Show("Do you want to add this Employee?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (dlg == System.Windows.Forms.DialogResult.OK) { Employee.Add(newEmLoadDownd()); MessageBox.Show("Adding is successful!", "Message Box", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.DialogResult = System.Windows.Forms.DialogResult.OK; } }
/// <summary> /// Add a new entry to the Employee table /// </summary> public static Employee AddEmployee(int personId, DateTime hireDate, Permissions[] permissions, byte[] scanCode, string federalTaxId) { Employee newEmployee = Employee.Add(personId, permissions, scanCode, federalTaxId); if (newEmployee != null) { EmployeeStatus.Add(newEmployee.Id, hireDate); Employees.Add(newEmployee.Id, newEmployee); } return(newEmployee); }
static void Main(string[] args) { // Here we are controlling which DAL we should use // The Employee class uses dependence inversion (DI) // to delegate the control (IOC) to this or another class that need to use it. Employee objOracle = new Employee(new OracleDAL()); objOracle.Add(); Employee objSQL = new Employee(new SqlDAL()); objSQL.Add(); }
private void Insert_Employee() { Employee repository = new Employee(); if (repository.Add(get_Data_From_Form())) { this.ShowSuccessfulNotification("Employee added successfully"); clear_form(); Load_Data_Grid(); } else { this.ShowErrorNotification("Error occured"); } }
public ActionResult Create(EmployeeDetailsViewModel employeeModel) { try { // TODO: Add insert logic here Employee employee = new Employee(employeeModel); Employee.Add(employee); return(RedirectToAction("Index")); } catch { return(View()); } }
/// <summary> /// Updates the database and the collection depending on selection, we remove and add from the Observable collection to trigger the propertyChanged so it can update teh view. /// </summary> /// <param name="obj"></param> public void updateEmployeeCommand(object obj) { if (employeeDB.updateEmployee(ID, FirstName, SecondName, ThirdName, FourthName, FamilyName, LatinName, CivilNum, BirthPlace, DOB, Gender, Religion, Nationality, Career, PassportNum, PassportEndDate, PassportType, Education, MaritalStatus, Salary, declration, ResidencyNum, ResidencyEndDate, StartDate, Duration, DurationEng, NationalityEng, CareerEng, Note, PassportIssueDate)) { var found = Employee.FirstOrDefault(x => x.ID == ID); Employee.Remove(found); Employee.Add(new Models.EmployeeModel { ID = ID, FirstName = FirstName, SecondName = SecondName, ThirdName = ThirdName, FourthName = FourthName, FamilyName = FamilyName, LatinName = LatinName, CivilNum = CivilNum, BirthPlace = BirthPlace, DOB = DOB, Gender = Gender, Religion = Religion, Nationality = Nationality, Career = Career, PassportNum = PassportNum, PassportEndDate = PassportEndDate, PassportType = PassportType, Education = Education, MaritalStatus = MaritalStatus, salary = salary, declration = declration, ResidencyNum = ResidencyNum, ResidencyEndDate = ResidencyEndDate, StartDate = StartDate, Duration = Duration, DurationEng = DurationEng, NationalityEng = NationalityEng, CareerEng = CareerEng, Note = Note, PassportIssueDate = PassportIssueDate, /* LicenseNumber = LicenseNumber, * LicenseEndDate = LicenseEndDate*/ }); } }
public void MasterPasswordConfirmed() { m_MasterPasswordForm.Close(); bool addResult = Employee.Add(new Employee(-1, txtFirstname.Text, txtLastname.Text, dateBirth.Value, txtAddress.Text, txtAddress2.Text, txtCity.Text, txtPostcode.Text, txtPhone.Text, txtUsername.Text, txtPassword.Text)); if (addResult) { //customer added successful if (MessageBox.Show("Employee Added!", "Success:", MessageBoxButtons.OK) == DialogResult.OK) { this.Close(); } } else { //handle the bad insert MessageBox.Show("Check your input!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Create a new data entry public async Task <Employee> CreateAsync(Employee employee) { try { Employee.Add(employee); await SaveChangesAsync(); } catch (DbUpdateException) { if (EmployeeExists(employee.EmployeeNumber)) { return(NotFound()); } else { throw; } } return(employee); }
public ActionResult Add(Employee b) { b.Add(); return(View()); }
private void Add_Click_Func(bool is_edit) { name = tb_name.Text.Replace('\'', ' '); surname = tb_surname.Text; email = tb_email.Text; department_id = int.Parse(cb_department.SelectedIndex.ToString()); password = Generate_Auto_Password(); lbl_message.Text = ""; if (tb_name.Text.Trim() == "Employee's Name" || tb_name.Text.Trim() == "") { lbl_message.Text = "* Please enter name."; lbl_message.ForeColor = Color.Red; tb_name.Focus(); return; } if (tb_surname.Text.Trim() == "Employee's Surname" || tb_surname.Text.Trim() == "") { lbl_message.Text = "* Please enter surname."; lbl_message.ForeColor = Color.Red; tb_surname.Focus(); return; } if (tb_email.Text.Trim() == "Employee's E-mail" || tb_email.Text.Trim() == "") { lbl_message.Text = "* Please enter e-mail."; lbl_message.ForeColor = Color.Red; tb_name.Focus(); return; } if (!is_a_valid_email(email)) { return; } if (rdo_male.Checked) { gender = "Male"; } else if (rdo_female.Checked) { gender = "Female"; } else { lbl_message.Text = "*Please select gender"; lbl_message.ForeColor = Color.Red; return; } if (is_edit == false) { if (picture_event.Pic_source_file != null && picture_event.Pic_source_file != picture_default_file) { picture_event.Copy_The_Picture(name); pic_new_source_path = picture_event.Pic_source_file; } else { pic_new_source_path = picture_default_file; } if (Employee.Contains_Email(email) != -1) { lbl_message.Text = "*That email is used by another employee"; lbl_message.ForeColor = Color.Red; return; } lbl_message.Text = "*Employee added successfully"; lbl_message.ForeColor = Color.Green; Employee employee = new Employee(0, department_id, name, surname, password, email, gender, dtp_time.Value, pic_new_source_path); employee.Add(); Clear(); } else { if (Employee.Contains_Email(email) != employee_to_edit.Employee_id && Employee.Contains_Email(email) != -1) { lbl_message.Text = "*That email is used by another employee"; lbl_message.ForeColor = Color.Red; return; } if (change_image) { if (employee_to_edit.Cover_path_file != picture_default_file) { Picture_Events.Delete_The_Picture(employee_to_edit.Cover_path_file); } picture_event.Copy_The_Picture(name); pic_new_source_path = picture_event.Pic_source_file; change_image = false; } lbl_message.Text = "*Employee changed successfully"; lbl_message.ForeColor = Color.LightGreen; employee_to_edit.Name = name; employee_to_edit.Surname = surname; employee_to_edit.Gender = gender; employee_to_edit.Email = email; employee_to_edit.Department_id = department_id; employee_to_edit.Cover_path_file = picture_event.Pic_source_file; employee_to_edit.Birth_date_dt = dtp_time.Value; employee_to_edit.Edit(); main_page.Pnl_employee_list.VerticalScroll.Value = 0; main_page.Main_employee_list.Delete_All_List(); Employee.Show_All_Employees(main_page.Department); main_page.Main_tag.lbl_author.Text = " "; main_page.Main_tag.lbl_bookname.Text = " "; main_page.Main_tag.pic_book.Visible = false; main_page.Main_tag.lbl_description.Text = " "; } }
static void Main(string[] args) { Console.WriteLine("Singleton Pattern"); // Singleton Pattern SingleObject singleObject = SingleObject.Instance(); singleObject.ShowMessage(); Console.WriteLine("\nBuilder Pattern"); // Builder Pattern MealBuilder mealBuilder = new MealBuilder(); Meal vegMeal = mealBuilder.PrepareVegMeal(); Console.WriteLine("Veg Meal"); vegMeal.ShowItems(); Console.WriteLine("Total Cost : " + vegMeal.GetCost()); Meal nonVegMeal = mealBuilder.PrepareNonVegMeal(); Console.WriteLine("NonVeg Meal"); nonVegMeal.ShowItems(); Console.WriteLine("Total Cost : " + nonVegMeal.GetCost()); Console.WriteLine("\nAbstract Factory"); // Abstract Factory Pattern AbstractFactory shapeFactory = FactoryProducer.GetFactory("shape"); IShape circleShape = shapeFactory.GetShape("circle"); circleShape.Draw(); AbstractFactory colorFactory = FactoryProducer.GetFactory("color"); IColor blueColor = colorFactory.GetColor("blue"); blueColor.Fill(); Console.WriteLine("\nAdapter"); //Adapter Pattern AudioPlayer audioPlayer = new AudioPlayer(); audioPlayer.Play("mp4"); audioPlayer.Play("flac"); audioPlayer.Play("vlc"); Console.WriteLine("\nFacade"); //Facade Pattern ShapeMaker shapeMaker = new ShapeMaker(); shapeMaker.DrawCircle(); shapeMaker.DrawRectangle(); shapeMaker.DrawSquare(); Console.WriteLine("\nDecorator doesn't work"); //Decorator Pattern IDecoratorShape rectangle = new RectangleDecorator(); IDecoratorShape redRectangle = new RedShapeDecorator(new RectangleDecorator()); Console.WriteLine("Rectangle with no color"); rectangle.Draw(); Console.WriteLine("Rectangle with color"); redRectangle.Draw(); Console.WriteLine("\nComposite"); //Composite Pattern Employee DSI = new Employee("employee1", "DSI", 100000); Employee chefDeProjet1 = new Employee("employee2", "Chef de projet", 60000); Employee chefDeProjet2 = new Employee("employee3", "Chef de projet", 60000); Employee dev1 = new Employee("employee4", "Développeur", 40000); Employee dev2 = new Employee("employee5", "Développeur", 40000); DSI.Add(chefDeProjet1); DSI.Add(chefDeProjet2); chefDeProjet1.Add(dev1); chefDeProjet2.Add(dev2); Console.WriteLine(DSI.Details()); foreach (Employee e1 in DSI.GetSubordinates()) { Console.WriteLine(e1.Details()); foreach (Employee e2 in e1.GetSubordinates()) { Console.WriteLine(e2.Details()); } } Console.WriteLine("\nBridge"); //Bridge Pattern BridgeShape shape1 = new BridgeCircle(10, 10, 1, new GreenCircle()); BridgeShape shape2 = new BridgeCircle(100, 100, 10, new RedCircle()); shape1.Draw(); shape2.Draw(); Console.WriteLine("\nCommand"); //Command Pattern Stock stock1 = new Stock("laptop", 100); BuyStock buyStock = new BuyStock(stock1); Stock stock2 = new Stock("screen", 30); SellStock sellStock = new SellStock(stock2); Broker broker = new Broker(); broker.TakeOrder(buyStock); broker.TakeOrder(sellStock); broker.PlaceOrders(); Console.WriteLine("\nInterpreter"); //Interpreter Pattern IExpression isMale = InterpreterPatternDemo.GetMaleExpression(); IExpression isMarried = InterpreterPatternDemo.GetMarriedWomanExpression(); Console.WriteLine("John is male ? " + isMale.Interpret("john")); Console.WriteLine("Barbara is male ? " + isMale.Interpret("barbara")); Console.WriteLine("Julie is married ? " + isMarried.Interpret("julie married")); Console.WriteLine("Bob is married ? " + isMarried.Interpret("bob married")); }
protected void btnSubmit_Click(object sender, EventArgs e) { string[] validFileTypes = { "doc", "docx" }; string ext = System.IO.Path.GetExtension(FileUploadResume.PostedFile.FileName); bool isValidFile = false; try { for (int i = 0; i < validFileTypes.Length; i++) { if (ext == "." + validFileTypes[i]) { isValidFile = true; break; } } if (!isValidFile) //checking whether the file is valid or not { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Invalid File. Only " + string.Join(",", validFileTypes) + " files are allowed.."; return; } Employee emp = new Employee(); emp.UserName = txtName.Text; emp.Email = txtEmail.Text.ToLower(); emp.Password = txtPassword.Text; emp.Gender = rbtnListGender.SelectedItem.ToString(); emp.DOB = txtDOB.Text.ToString(); emp.Mobile = txtMobile.Text; emp.Country = txtCountry.Text; emp.City = txtCity.Text; emp.Address = txtAddress.Text; if (chkPhysical.Checked == true) { emp.physicallyChallenged = "yes"; } else { emp.physicallyChallenged = "NO"; } if (FileUploadResume.HasFile) { Stream fs = FileUploadResume.PostedFile.InputStream; emp.AttachedFileName = FileUploadResume.FileName.ToString(); BinaryReader br = new BinaryReader(fs); emp.AttachedFileData = br.ReadBytes((Int32)fs.Length); br.Close(); fs.Close(); } //Adding Employee emp.Add(); lblMessage.ForeColor = System.Drawing.Color.Green; lblMessage.Text = "Employee Added successfully"; } catch (Exception ex) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = ex.Message; return; } }
private EmployeeRepository() { Employee CEO = new Employee(1, "John", "CEO", 30000, 0); CEO.SetTier(0); Employee VPMarketing = new Employee(2, "Robert", "Head Marketing", 20000, CEO.GetId()); VPMarketing.SetTier(1); Employee VPManufacturing = new Employee(3, "Michel", "Head Manufacturing", 20000, CEO.GetId()); VPManufacturing.SetTier(1); Employee VPSales = new Employee(4, "Laura", "Head Sales", 20000, CEO.GetId()); VPSales.SetTier(1); Employee MarketingExec1 = new Employee(5, "Richard", "Marketing", 10000, VPMarketing.GetId()); MarketingExec1.SetTier(2); Employee MarketingExec2 = new Employee(6, "Rob", "Marketing", 10000, VPMarketing.GetId()); MarketingExec2.SetTier(2); Employee SalesExec1 = new Employee(7, "Scott", "Sales", 10000, VPSales.GetId()); SalesExec1.SetTier(2); Employee SalesExec2 = new Employee(8, "Hope", "Sales", 10000, VPSales.GetId()); SalesExec2.SetTier(2); Employee ManufacturingExec1 = new Employee(9, "Ada", "Manufacturing", 10000, VPManufacturing.GetId()); ManufacturingExec1.SetTier(2); Employee ManufacturingExec2 = new Employee(10, "Hank", "Manufacturing", 10000, VPManufacturing.GetId()); ManufacturingExec2.SetTier(2); CEO.Add(VPSales); CEO.Add(VPMarketing); CEO.Add(VPManufacturing); VPSales.Add(SalesExec1); VPSales.Add(SalesExec2); VPMarketing.Add(MarketingExec1); VPMarketing.Add(MarketingExec2); VPManufacturing.Add(ManufacturingExec1); VPManufacturing.Add(ManufacturingExec2); _employees = new List <Employee> { CEO, VPMarketing, VPManufacturing, VPSales, MarketingExec1, MarketingExec2, SalesExec1, SalesExec2, ManufacturingExec1, ManufacturingExec2 }; }
private void uxAdd_Click(object sender, EventArgs e) { try { //Validate the First Name field if (Validator.IsEmpty(uxFirstName.Text)) { //Call display message method DisplayMessage("First Name cannot be empty"); uxFirstName.Focus(); return; } else if (!Validator.IsAlpha(uxFirstName.Text)) { DisplayMessage("First Name can only contain letters and first letter must be capital."); uxFirstName.Focus(); return; } //Validate the Last Name field if (Validator.IsEmpty(uxLastName.Text)) { //Call display message method DisplayMessage("Last Name cannot be empty"); uxLastName.Focus(); return; } else if (!Validator.IsAlpha(uxLastName.Text)) { DisplayMessage("Last Name can only contain letters and first letter must be capital."); uxLastName.Focus(); return; } //Validate the phone number field if (Validator.IsEmpty(uxPhone.Text)) { //Call display message method DisplayMessage("Phone Number Required!"); uxPhone.Focus(); return; } else if (!Validator.IsPhoneFormat(uxPhone.Text)) { DisplayMessage("Invalid Phone number! Use xxx-xxxx format for phone number."); uxPhone.Focus(); return; } Employee emp = new Employee(uxFirstName.Text, uxLastName.Text, uxDepartmentCombo.SelectedItem.ToString(), uxPhone.Text); Employee.Add(emp, UserName); DisplayMessage("Employee added successfully."); uxFirstName.Clear(); uxLastName.Clear(); uxPhone.Clear(); uxDepartmentCombo.SelectedIndex = 0; uxFirstName.Focus(); } catch (Exception ex) { DisplayMessage(ex.Message); uxFirstName.Focus(); } }
public string PostEmployee(Employee employee) { employee.Add(); return("insert successfully"); }
private void btnOk_Click(object sender, EventArgs e) { if (lvwDept.Items.Count == 0) { MessageBox.Show("没有指定人员的科室!"); return; } if (txtDocCode.Enabled && txtDocCode.Text.Trim() == "") { MessageBox.Show("没有指定医生代码", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lvwGroup.Items.Count == 0 && txtUserCode.Text.Trim( ) != "") { MessageBox.Show("设置了用户名的人员,隶属组不能为空", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool add; if (employee == null) { employee = new Employee( ); add = true; } else { if (txtUserCode.Text.Trim( ) == "") { if (MessageBox.Show("没有为该人员指定用户信息,是否继续?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } add = false; } employee.Name = txtName.Text; employee.NotUse = chkNoUse.Checked ? 1 : 0; employee.Role = cboRole.SelectedIndex; employee.DocCode = txtDocCode.Text; employee.CFQ = chkCf.Checked ? 1 : 0; employee.MZQ = chkMz.Checked ? 1 : 0; employee.DMQ = chkDm.Checked ? 1 : 0; employee.UserCode = txtUserCode.Text.Trim(); employee.doctor_typeId = cboDocType.Enabled?cboDocType.SelectedValue.ToString():""; string[] pywb = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.GetPyWbCode(employee.Name); employee.PY_Code = pywb[0]; employee.WB_Code = pywb[1]; int[] depts = new int[lvwDept.Items.Count]; for (int i = 0; i < lvwDept.Items.Count; i++) { depts[i] = ((Department)lvwDept.Items[i].Tag).DeptID; } employee.DeptIds = depts; int[] groups = new int[lvwGroup.Items.Count]; for (int i = 0; i < lvwGroup.Items.Count; i++) { groups[i] = Convert.ToInt32(lvwGroup.Items[i].Tag); } employee.GroupIds = groups; try { if (add) { employee.Add( ); txtName.Text = ""; cboRole.SelectedIndex = 0; lvwDept.Items.Clear( ); txtUserCode.Text = ""; lvwGroup.Items.Clear( ); chkCf.Checked = false; chkMz.Checked = false; chkDm.Checked = false; ListViewItem item = new ListViewItem( ); item.Text = employee.Name; item.SubItems.Add(employee.UserCode == null?"":employee.UserCode); item.Tag = employee; item.ImageIndex = 2; lvw.Items.Add(item); employee = null; } else { employee.Update( ); lvw.SelectedItems[0].Text = employee.Name; lvw.SelectedItems[0].SubItems[1].Text = employee.UserCode; lvw.SelectedItems[0].Tag = employee; this.DialogResult = DialogResult.OK; this.Close( ); } } catch (Exception err) { if (add) { employee = null; } MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void AddEmployee(EmployeePO employee) { _daoEmployee.Add(employee); }