public override Control AddTo(Control container) { Hr hr = new Hr(); container.Controls.Add(hr); return(hr); }
public void CreateHr(Hr Hr) { using (var repository = new CommonRepository <Hr>()) { repository.Create(Hr); } }
public ActionResult HrRegistration(Hr Hr) { var hrManager = new HrManager(); hrManager.CreateHr(Hr); return(View("Index")); }
public override System.Web.UI.Control AddTo(System.Web.UI.Control container) { var hr = new Hr(); container.Controls.Add(hr); return(hr); }
static void Main() { //Employee[] repository = CreateRepository(); //InsertRecord(repository); //ShowRecords(repository); Developer developer = new Developer(1, "anil", "CITA", 1000, 2000, 3000, 4000); Hr hr = new Hr(2, "sunil", "CITA", 1500, 2500, 3500, 4500); PrintInfo(developer); PrintInfo(hr); }
public ActionResult Details(int?_ID) { // 如果沒有修改 /App_Start/RouteConfig.cs,網址輸入 http://xxxxxx/UserDB/Details/2 會報錯! if (_ID == null || _ID.HasValue == false) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } // 第四種寫法:透過 .Find() 函數 Hr ut = _db.Hrs.Find(_ID); // 翻譯成SQL指令的結果,同上(第一種方法) //如果有老闆 if (!string.IsNullOrEmpty(ut.Boss)) { var BossName = from _hr in _db.Hrs where _hr.MemberID == ut.Boss select _hr.Name; ViewBag.BossName = BossName.FirstOrDefault().ToString(); } else { ViewBag.BossName = ""; } DateTime Today = DateTime.Now; var age = CalculationDate.AGE(ut.Birthday, Today); ViewBag.age = age; //在職 if (ut.Status != 2) { var service = CalculationDate.Seniority(ut.StartDate, Today); ViewBag.service = service; } else { var service = CalculationDate.Seniority(ut.StartDate, ut.EndDate); ViewBag.service = service; } if (ut == null) { // 找不到這一筆記錄 return(HttpNotFound()); } else { return(View(ut)); } }
static Employee CreateEmployee(int choice) { Employee emp = null; switch (choice) { case 1: emp = new Developer(); break; case 2: emp = new Hr(); break; default: Console.WriteLine("Not correct option"); break; } Console.Write("Name : "); emp.Name = Console.ReadLine(); Console.Write("Id : "); emp.Id = int.Parse(Console.ReadLine()); Console.Write("Basic Pay : "); emp.BasicPay = double.Parse(Console.ReadLine()); Console.Write("Hra : "); emp.Hra = double.Parse(Console.ReadLine()); Console.Write("daPay : "); emp.DaPay = double.Parse(Console.ReadLine()); if (emp is Developer) { Console.Write("Incentive : "); ((Developer)emp).Incentive = double.Parse(Console.ReadLine()); } if (emp is Hr) { Console.Write("Gratuity Pay : "); ((Hr)emp).GratuityPay = double.Parse(Console.ReadLine()); } return(emp); }
public static List <StaticResourceDto> GetAllPrivateResources() { var list = new List <StaticResourceDto>(); list.AddRange(DataPermission.GetAll()); list.AddRange(MultiTenant.GetAll()); list.AddRange(Common.GetAll()); list.AddRange(Landing.GetAll()); list.AddRange(Administration.GetAll()); list.AddRange(Purchase.GetAll()); list.AddRange(Sales.GetAll()); list.AddRange(Stock.GetAll()); list.AddRange(Hr.GetAll()); return(list); }
private void timer_Tick(object sender, EventArgs e) { Seg++; if (Seg == 60) { Min++; Seg = 0; } if (Min == 60) { Hr++; Min = 0; } lblTiempo.Text = Hr.ToString("00") + ":" + Min.ToString("00") + ":" + Seg.ToString("00"); }
//Employee is a concrete class static Employee Create(int empChoice) { Employee employee = null; Console.Write("\nName: "); string employeeName = Console.ReadLine(); Console.Write("\nId: "); int id = int.Parse(Console.ReadLine()); Console.Write("Locaton: "); string employeeLocation = Console.ReadLine(); Console.Write("Project Name: "); string projectName = Console.ReadLine(); Console.Write("Basic Pay: "); decimal employeeBasicPayemnt = decimal.Parse(Console.ReadLine()); Console.Write("Da Pay: "); decimal employeeDaPayemnt = decimal.Parse(Console.ReadLine()); Console.Write("Hra Pay: "); decimal employeeHraPayemnt = decimal.Parse(Console.ReadLine()); switch (empChoice) { case 1: Console.Write("Incentive Pay: "); decimal incentivePayemnt = decimal.Parse(Console.ReadLine()); employee = new Developer(id, employeeName, employeeLocation, projectName, employeeBasicPayemnt, employeeDaPayemnt, employeeHraPayemnt, incentivePayemnt); break; case 2: Console.Write("Gratuity Pay: "); decimal gratuityPayemnt = decimal.Parse(Console.ReadLine()); employee = new Hr(id, employeeName, employeeLocation, projectName, employeeBasicPayemnt, employeeDaPayemnt, employeeHraPayemnt, gratuityPayemnt); break; default: break; } return(employee); }
static void Main(string[] args) { Hr hr = new Hr(); Console.WriteLine(hr.GetMsg()); Employee emp = new Employee(); Console.WriteLine(emp.GetMsg()); Account account = new Account(); Console.WriteLine(account.GetMsg()); Admin admin = new Admin(); Console.WriteLine(admin.GetMsg()); }
public ActionResult Edit(int?_ID) { if (_ID == null) { // 沒有輸入文章編號(_ID),就會報錯 - Bad Request return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } // 使用上方 Details動作的程式,先列出這一筆的內容,給使用者確認 Hr ut = _db.Hrs.Find(_ID); if (ut == null) { // 找不到這一筆記錄 return(HttpNotFound()); } else { return(View(ut)); } }
public ActionResult List(Hr _hr) { //第一種寫法: //*** 查詢結果是一個 IQueryable ******************************************* IQueryable <Hr> ListAll = from _List in _db.Hrs select _List; // 從畫面上,輸入的第一個搜尋條件。 姓名。 string uStatus = _hr.Status.ToString(); if (!string.IsNullOrWhiteSpace(uStatus)) { ListAll = ListAll.Where(s => s.Status == _hr.Status); } if (!string.IsNullOrWhiteSpace(_hr.Dep)) { ListAll = ListAll.Where(s => s.Dep.Contains(_hr.Dep)); // / } return(View("List", ListAll)); }
static Employee Create(int choice) { Console.Write("\nName: "); string name = Console.ReadLine(); Console.Write("Id: "); int id = int.Parse(Console.ReadLine()); Console.Write("Basic: "); decimal basic = decimal.Parse(Console.ReadLine()); Console.Write("Da: "); decimal da = decimal.Parse(Console.ReadLine()); Console.Write("Hra: "); decimal hra = decimal.Parse(Console.ReadLine()); Employee employee = null; switch (choice) { case 1: Console.Write("Incentive: "); decimal incentive = decimal.Parse(Console.ReadLine()); employee = new Developer(name, id, basic, da, hra, incentive, Designation.JuniorDeveloper); break; case 2: Console.Write("Gratuity: "); decimal gratuity = decimal.Parse(Console.ReadLine()); employee = new Hr(name, id, basic, da, hra, gratuity, Designation.Hr); break; default: break; } return(employee); }
/// <summary> /// Method to accept values for an employee from user and create an object based on that data /// </summary> /// <param name="empType">choice of employee: either developer (if the value is 1) or hr (if the value is 2)</param> /// <returns> /// returns reference of the Employee class object /// </returns> static Employee AcceptValuesandCreateObject(int empType) { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Id: "); int id = int.Parse(Console.ReadLine()); Console.Write("Basic Payment: "); decimal basic = decimal.Parse(Console.ReadLine()); Console.Write("Da Payment: "); decimal da = decimal.Parse(Console.ReadLine()); Console.Write("Hra Payment: "); decimal hra = decimal.Parse(Console.ReadLine()); Employee employee = null; switch (empType) { case 1: Console.Write("Incentive Payment: "); decimal incentive = decimal.Parse(Console.ReadLine()); employee = new Developer(name, id, basic, da, hra, incentive); break; case 2: Console.Write("Gratuity Payment: "); decimal gratuity = decimal.Parse(Console.ReadLine()); employee = new Hr(name, id, basic, da, hra, gratuity); break; default: break; } return(employee); }
static void Main(string[] args) { LeaveRequest request = new LeaveRequest { Employee = "john", LeaveDays = 34 }; ILeaveRequestHandler supervisor = new Supervisor(); ILeaveRequestHandler manager = new ProjectManager(); ILeaveRequestHandler hr = new Hr(); // set linking supervisor -- manager -- hr // 2 supervisor.NextHandler = manager; manager.NextHandler = hr; supervisor.HandleRequest(request); request.LeaveDays = 14; supervisor.HandleRequest(request); request.LeaveDays = 4; supervisor.HandleRequest(request); Console.ReadLine(); }
static void Main() { Program p = new Program(); p.Add(12, 13); //1. //Employee.BonusPayment = 1000; //Employee.Foo(); //Employee.SetBonusPayment(1000); //Console.WriteLine(Employee.BonusPayment); //Console.WriteLine(Employee.GetBonusPayment()); Developer anilDeveloper = new Developer(basic: 1000, da: 2000, hra: 3000, incentive: 4000); anilDeveloper.CalculateSalary(); Console.WriteLine(anilDeveloper.TotalSalary); //Developer sunilDeveloper = new Developer(); Hr kamakshiHr = new Hr(basic: 1500, da: 2500, hra: 3500, gratuity: 4500); //Hr joydipHr = new Hr(); //Employee.BonusPayment = 2000; }
[ValidateAntiForgeryToken] // 避免CSRF攻擊 public ActionResult Create(Hr _hr) { using (SqlConnection Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["CGH"].ConnectionString)) { Conn.Open(); if (_hr != null) // ModelState.IsValid,通過表單驗證(Server-side validation)需搭配 Model底下類別檔的 [驗證] {//體檢日不為null if (_hr.MEdate.ToString() != "0001/1/1 上午 12:00:00") { string sqlstr = "INSERT INTO [Hr] ( [MemberID],[Status],[Name],[IDcardNO],[Birthday],[Nationality],[StartDate],[Labor],[Hire],[Dep],[TitleID],[Boss],[Manager],[Remarks],[Marriage],[Blood],[Sex],[Height],[Weight],[Military],[MEdate],[Birthplace],[Email],[MobilePhone],[HomePhone],[Address1],[Postal1],[Address2],[Postal2],[Emergency],[Relationship],[Ephone],[Highestedu],[Graduation])"; sqlstr += " VALUES (@MemberID,@Status,@Name,@IDcardNO,@Birthday,@Nationality,@StartDate,@Labor,@Hire,@Dep,@TitleID,@Boss,@Manager,@Remarks,@Marriage,@Blood,@Sex,@Height,@Weight,@Military,@MEdate,@Birthplace,@Email,@MobilePhone,@HomePhone,@Address1,@Postal1,@Address2,@Postal2,@Emergency,@Relationship,@Ephone,@Highestedu,@Graduation)"; int affectedRows = Conn.Execute(sqlstr, new { MemberID = _hr.MemberID, Status = _hr.Status, Name = _hr.Name, IDcardNO = _hr.IDcardNO, Birthday = _hr.Birthday, Nationality = _hr.Nationality, StartDate = _hr.StartDate, Labor = _hr.Labor, Hire = _hr.Hire, Dep = _hr.Dep, TitleID = _hr.TitleID, Boss = _hr.Boss, Manager = _hr.Manager, Remarks = _hr.Remarks, Marriage = _hr.Marriage, Blood = _hr.Blood, Sex = _hr.Sex, Height = _hr.Height, Weight = _hr.Weight, Military = _hr.Military, MEdate = _hr.MEdate, Birthplace = _hr.Birthplace, Email = _hr.Email, MobilePhone = _hr.MobilePhone, HomePhone = _hr.HomePhone, Address1 = _hr.Address1, Postal1 = _hr.Postal1, Address2 = _hr.Address2, Postal2 = _hr.Postal2, Emergency = _hr.Emergency, Relationship = _hr.Relationship, Ephone = _hr.Ephone, Highestedu = _hr.Highestedu, Graduation = _hr.Graduation } ); } else { string sqlstr = "INSERT INTO [Hr] ( [MemberID],[Status],[Name],[IDcardNO],[Birthday],[Nationality],[StartDate],[Labor],[Hire],[Dep],[TitleID],[Boss],[Manager],[Remarks],[Marriage],[Blood],[Sex],[Height],[Weight],[Military],[Birthplace],[Email],[MobilePhone],[HomePhone],[Address1],[Postal1],[Address2],[Postal2],[Emergency],[Relationship],[Ephone],[Highestedu],[Graduation])"; sqlstr += " VALUES (@MemberID,@Status,@Name,@IDcardNO,@Birthday,@Nationality,@StartDate,@Labor,@Hire,@Dep,@TitleID,@Boss,@Manager,@Remarks,@Marriage,@Blood,@Sex,@Height,@Weight,@Military,@Birthplace,@Email,@MobilePhone,@HomePhone,@Address1,@Postal1,@Address2,@Postal2,@Emergency,@Relationship,@Ephone,@Highestedu,@Graduation)"; int affectedRows = Conn.Execute(sqlstr, new { MemberID = _hr.MemberID, Status = _hr.Status, Name = _hr.Name, IDcardNO = _hr.IDcardNO, Birthday = _hr.Birthday, Nationality = _hr.Nationality, StartDate = _hr.StartDate, Labor = _hr.Labor, Hire = _hr.Hire, Dep = _hr.Dep, TitleID = _hr.TitleID, Boss = _hr.Boss, Manager = _hr.Manager, Remarks = _hr.Remarks, Marriage = _hr.Marriage, Blood = _hr.Blood, Sex = _hr.Sex, Height = _hr.Height, Weight = _hr.Weight, Military = _hr.Military, Birthplace = _hr.Birthplace, Email = _hr.Email, MobilePhone = _hr.MobilePhone, HomePhone = _hr.HomePhone, Address1 = _hr.Address1, Postal1 = _hr.Postal1, Address2 = _hr.Address2, Postal2 = _hr.Postal2, Emergency = _hr.Emergency, Relationship = _hr.Relationship, Ephone = _hr.Ephone, Highestedu = _hr.Highestedu, Graduation = _hr.Graduation }); } return(RedirectToAction("List")); } else { // 搭配 ModelState.IsValid,如果驗證沒過,就出現錯誤訊息。 ModelState.AddModelError("Value1", " 自訂錯誤訊息(1) "); // 第一個輸入值是 key,第二個是錯誤訊息(字串) ModelState.AddModelError("Value2", " 自訂錯誤訊息(2) "); return(View()); // 將錯誤訊息,返回並呈現在「新增」的檢視畫面上 } } }
public ActionResult Edit(Hr _userTable) { // 參考資料 http://blog.kkbruce.net/2011/10/aspnet-mvc-model-binding6.html if (_userTable == null) { // 沒有輸入內容,就會報錯 - Bad Request return(Content(" *** 最前端失敗!!*** ")); /*new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)*/; } if (ModelState.IsValid) // ModelState.IsValid,通過表單驗證(Server-side validation)需搭配 Model底下類別檔的 [驗證] { //_db.Entry(_userTable).State = System.Data.Entity.EntityState.Modified; //確認被修改(狀態:Modified) //_db.SaveChanges(); // 第二種寫法:========================================= (start) //使用上方 Details動作的程式,先列出這一筆的內容,給使用者確認 Hr ut = _db.Hrs.Find(_userTable.ID); if (ut == null) { // 找不到這一筆記錄 return(Content(" *** 二階段失敗!!*** ")); } else { ut.Name = _userTable.Name; ut.IDcardNO = _userTable.IDcardNO; ut.Birthday = _userTable.Birthday; ut.Nationality = _userTable.Nationality; ut.StartDate = _userTable.StartDate; ut.Labor = _userTable.Labor; ut.Hire = _userTable.Hire; ut.Dep = _userTable.Dep; ut.TitleID = _userTable.TitleID; ut.Boss = _userTable.Boss; ut.Manager = _userTable.Manager; ut.Remarks = _userTable.Remarks; ut.Marriage = _userTable.Marriage; ut.Blood = _userTable.Blood; ut.Sex = _userTable.Sex; ut.Height = _userTable.Height; ut.Weight = _userTable.Weight; ut.Military = _userTable.Military; ut.MEdate = _userTable.MEdate; ut.Birthplace = _userTable.Birthplace; ut.Email = _userTable.Email; ut.MobilePhone = _userTable.MobilePhone; ut.HomePhone = _userTable.HomePhone; ut.Address1 = _userTable.Address1; ut.Postal1 = _userTable.Postal1; ut.Address2 = _userTable.Address2; ut.Postal2 = _userTable.Postal2; ut.Emergency = _userTable.Emergency; ut.Relationship = _userTable.Relationship; ut.Ephone = _userTable.Ephone; ut.Highestedu = _userTable.Highestedu; ut.Graduation = _userTable.Graduation; _db.SaveChanges(); // 回寫資料庫(進行修改) } //return Content(" 更新一筆記錄,成功!"); // 更新成功後,出現訊息(字串)。 return(RedirectToAction("List")); } else { return(View(_userTable)); // 若沒有修改成功,則列出原本畫面 //return Content(" *** 更新失敗!!*** "); } }