private void FormStaffEdit_Load(object sender, EventArgs e) { // 性别下拉框初始化 comboBoxSex.Items.Add("男"); comboBoxSex.Items.Add("女"); comboBoxSex.SelectedIndex = 0; //学历下拉框初始化 comboBoxEdu.Items.Add("小学"); comboBoxEdu.Items.Add("中学"); comboBoxEdu.Items.Add("高中"); comboBoxEdu.Items.Add("专科"); comboBoxEdu.Items.Add("本科"); comboBoxEdu.Items.Add("硕士"); comboBoxEdu.Items.Add("博士"); comboBoxEdu.Items.Add("其他"); comboBoxEdu.SelectedIndex = 4; // 初始化下拉框值 ComboBoxExtend.initComboBox(this.comboBoxProfile, ROLE, true); ComboBoxExtend.initComboBox(this.comboBoxType, STAFF_TYPE, true); if (!m_isAdd) { this.buttonAdd.Enabled = false; m_staff = Staff.getInctance().getStaffInfoFromPkey(m_staffPkey); comboBoxSex.SelectedIndex = 0; comboBoxEdu.SelectedIndex = 0; setPageActiveValue(); } m_isInit = true; }
public ActionResult Edit(StaffTable staffTable) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } int userid = Convert.ToInt32(Convert.ToString(Session["UserID"])); staffTable.UserID = userid; if (ModelState.IsValid) { var folder = "/Content/EmployeePhoto"; var file = string.Format("{0}.png", staffTable.StaffID); var response = FileHelper.UploadFile.UploadPhoto(staffTable.PhotoFile, folder, file); if (response) { var pic = string.Format("{0}/{1}", folder, file); staffTable.Photo = pic; } db.Entry(staffTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DesignationID = new SelectList(db.DesignationTables, "DesignationID", "Title", staffTable.DesignationID); ViewBag.UserID = new SelectList(db.UserTables, "UserID", "FullName", staffTable.UserID); return(View(staffTable)); //TempData["msg"] = "<script>alert('Change succesfully');</script>"; }
public StaffTable InsertStaff(StaffTable staff) { var inserted = iTIDataEntities.StaffTables.Add(staff); iTIDataEntities.SaveChanges(); return(inserted); }
public void ReadAll_Create3Records_CountIs3() { //Assemble StaffModel staffModel1 = new StaffModel(); staffModel1.name = "Bob"; StaffModel staffModel2 = new StaffModel(); staffModel2.name = "Bob2"; StaffModel staffModel3 = new StaffModel(); staffModel3.name = "Bob3"; StaffTable staffTable = new StaffTable(); int expected = 3; //Act int staffID1 = staffTable.create(staffModel1); int staffID2 = staffTable.create(staffModel2); int staffID3 = staffTable.create(staffModel3); List <StaffModel> actual = staffTable.readAll(); //Assert Assert.AreEqual(expected, actual.Count); }
public void ReadAll_Create3Records_3DifferentRecords() { //Assemble StaffModel staffModel1 = new StaffModel(); staffModel1.name = "name1"; StaffModel staffModel2 = new StaffModel(); staffModel2.name = "name2"; StaffModel staffModel3 = new StaffModel(); staffModel3.name = "name3"; StaffTable staffTable = new StaffTable(); //Act int staffID1 = staffTable.create(staffModel1); int staffID2 = staffTable.create(staffModel2); int staffID3 = staffTable.create(staffModel3); List <StaffModel> actual = staffTable.readAll(); //Assert Assert.AreEqual(staffID1, staffID1); Assert.AreEqual(staffModel1.name, actual[0].name); Assert.AreEqual(staffID2, staffID2); Assert.AreEqual(staffModel2.name, actual[1].name); Assert.AreEqual(staffID3, staffID3); Assert.AreEqual(staffModel3.name, actual[2].name); }
private void populateStaff() { StaffTable staffTable = new StaffTable(); StaffModel staffModelAllison = new StaffModel(); staffModelAllison.name = "Allison"; staffIdAllison = staffTable.create(staffModelAllison); StaffModel staffModelBeth = new StaffModel(); staffModelAllison.name = "Beth"; staffIdBeth = staffTable.create(staffModelAllison); StaffModel staffModelCarol = new StaffModel(); staffModelCarol.name = "Carol"; staffIdCarol = staffTable.create(staffModelCarol); StaffModel staffModelDiane = new StaffModel(); staffModelDiane.name = "Diane"; staffIdDiane = staffTable.create(staffModelDiane); StaffModel staffModelEva = new StaffModel(); staffModelEva.name = "Eva"; staffIdEva = staffTable.create(staffModelDiane); }
public void Setup() { new DataStoreTableHelper().clearAllTables(); ProgramVarietyModel programeVarietyModel = new ProgramVarietyModel(); programeVarietyModel.depositAmount = 20.0; programeVarietyModel.sessionCost = 20.0; programeVarietyModel.fullPaymentPercentageDiscount = 20; programeVarietyModel.name = "Regular"; programeVarietyModel.dogSpacesMaximum = 50; programeVarietyModel.noOfClasses = 50; ProgramVarietyTable programVarietyTable = new ProgramVarietyTable(); programeCostId = programVarietyTable.create(programeVarietyModel); ProgramModel programModel = new ProgramModel(); programModel.programVarietyId = programeCostId; ProgramTable programTable = new ProgramTable(); programId = programTable.create(programModel); StaffModel staffModel = new StaffModel(); staffModel.name = "Bob"; StaffTable staffTable = new StaffTable(); staffId = staffTable.create(staffModel); }
public ActionResult AddStaff(int id = 0) { StaffTable staffTable = new StaffTable(); if (id > 0) { staffTable = staffRepository.GetStaffById(id); } ViewBag.Session = StaticData.GetStaffAT(); StaffModel staffModel = new StaffModel() { ID = staffTable.ID, ACDetails = staffTable.ACDetails, DateOfBirth = staffTable.DateOfBirth, DateOfJoin = staffTable.DateOfJoin, Designation = staffTable.Designation, Salary = staffTable.Salary, Experience = staffTable.Experience, SchoolMatric = staffTable.SchoolMatric, Name = staffTable.Name, PhotoGraph = staffTable.PhotoGraph, Staff = staffTable.Staff, Qualification = staffTable.Qualification }; return(View(staffModel)); }
// GET: Staff/Delete/5 public ActionResult Delete(StaffTable staffID) { var d = instance.StaffTables.Where(x => x.id == staffID.id).FirstOrDefault(); instance.StaffTables.Remove(d); instance.SaveChanges(); return(RedirectToAction("EmployeeList")); }
// GET: Student/Delete/5 public ActionResult Delete(StaffTable studentToDelete) { var d = obj_student.StudentTables.Where(x => x.id == studentToDelete.ID).FirstOrDefault(); obj_student.StudentTables.Remove(d); obj_student.SaveChanges(); return(RedirectToAction("ViewStudent")); }
private void InitStaffTable() { StaffTable.InitTableHeightWidth(420, 458); StaffTable.SetCanUserAddRows(false); StaffTable.SetCanUserDeletRows(true); StaffTable.AddColumns("RyId", "人员编号", 100); StaffTable.AddColumns("RyName", "姓名", 100); StaffTable.AddColumns("Sex", "性别", 100); StaffTable.AddColumns("Dep_Id", "所在部门编号", 140); }
public ActionResult Delete(int id = 0) { StaffTable staffTable = new StaffTable(); if (id > 0) { staffRepository.DeleteStaff(id); } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Exclude = "Id")] StaffTable AddStaff) { if (!ModelState.IsValid) { return(View()); } obj_staff.StaffTables.Add(AddStaff); obj_staff.SaveChanges(); return(RedirectToAction("ViewStaff")); }
public DepartmentStaff() { InitializeComponent(); InitDepartmentTable(); InitStaffTable(); DepartmentTable.DataTableSelect("select * from Departments", "更新"); DepartmentsNum.Content = infnum.InfTotalSet("Departments"); StaffTable.DataTableSelect("select * from ArmsPerson", "更新"); RyNum.Content = infnum.InfTotalSet("ArmsPerson"); InitRightBm(); }
public ActionResult Create(StaffTable staffData) { //following the concept of crud to register new employee if (!ModelState.IsValid) { return(View()); } instance.StaffTables.Add(staffData); instance.SaveChanges(); return(RedirectToAction("EmployeeList")); }
public ActionResult DeleteConfirmed(int id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } StaffTable staffTable = db.StaffTables.Find(id); db.StaffTables.Remove(staffTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Count_AllRecordsDeleted_0() { //Assemble int expected = 0; StaffTable staffTable = new StaffTable(); //Act int actual = staffTable.count(); //Assert Assert.AreEqual(expected, actual); }
public ActionResult Edit(StaffTable studentToEdit) { var orignalRecord = (from m in obj_student.StudentTables where m.id == studentToEdit.ID select m).First(); if (!ModelState.IsValid) { return(View(orignalRecord)); } obj_student.Entry(orignalRecord).CurrentValues.SetValues(studentToEdit); obj_student.SaveChanges(); return(RedirectToAction("ViewStudent")); }
private void addStaff() { StaffTable staff = getPageStaffActiveData(); if (Staff.getInctance().isExistStaffName(staff.name)) { MessageBoxExtend.messageWarning("已存在[" + staff.name + "]用户,请适量修改用户名后重新保存"); } else { Staff.getInctance().insert(staff); } }
public ActionResult Edit(StaffTable staffID) { var orignalRecord = (from m in instance.StaffTables where m.id == staffID.id select m).First(); if (!ModelState.IsValid) { return(View(orignalRecord)); } instance.Entry(orignalRecord).CurrentValues.SetValues(staffID); instance.SaveChanges(); return(RedirectToAction("EmployeeList")); }
public void Delete_NonExistantId_0() { //Assemble StaffTable staffTable = new StaffTable(); int expected = 0; //Act staffTable.delete(0); int actual = staffTable.count(); //Assert Assert.AreEqual(expected, actual); }
public void StaffEventContent(object sender, RoutedEventArgs e) { Staffmoinf = new MoreInf(); string[] Table_Str = { "RyId", "RyName", "Sex", "Nationalty", "Birth", "Title", "Rank", "Political_Party", "Culture_Level", "Marital_Condition", "Family_Place", "Id_Card", "Dep_Id", "Position", "UpperId" }; if (StaffTable.dataGrid.SelectedIndex != -1) { Staffmoinf.SetValues(StaffTable.Getdt(), StaffTable.dataGrid.SelectedIndex, StaffTable.Rows, Table_Str, StrRy, 15); Staffmoinf.Show(); } else { MessageBox.Show("当前未选中任何行!"); } }
public ActionResult AddStaff(StaffModel staffModel) { try { if (staffModel.FileName.ContentLength > 0) { if (ModelState.IsValid) { string _PhotoName = Path.GetFileName(staffModel.FileName.FileName).Replace(" ", ""); string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _PhotoName); staffModel.FileName.SaveAs(_path); StaffTable staffTable = new StaffTable() { ID = staffModel.ID, ACDetails = staffModel.ACDetails, DateOfBirth = staffModel.DateOfBirth, DateOfJoin = staffModel.DateOfJoin, Designation = staffModel.Designation, Salary = staffModel.Salary, Experience = staffModel.Experience, SchoolMatric = staffModel.SchoolMatric, Name = staffModel.Name, Staff = staffModel.Staff, Qualification = staffModel.Qualification, PhotoGraph = "/UploadedFiles/" + _PhotoName }; if (staffTable.ID > 0) { staffRepository.UpdateStaff(staffTable); } else { staffRepository.InsertStaff(staffTable); } } } else { return(View(staffModel)); } return(RedirectToAction("Technical")); } catch (Exception) { return(View(staffModel)); } }
public void Read_CreatedAndRead1Record_CorrectValues() { //Assemble StaffModel staffModel = new StaffModel(); staffModel.name = "Bob"; StaffTable staffTable = new StaffTable(); //Act int staffID = staffTable.create(staffModel); StaffModel actual = staffTable.read(staffID); //Assert Assert.AreEqual(staffModel.name, actual.name); }
public void InitRightBm() { MenuItem DepartmentMenu = DepartmentTable.AddMenuItem("更多信息"); MenuItem StaffMenu = StaffTable.AddMenuItem("更多信息"); MenuItem DeletRowMenu1 = DepartmentTable.AddMenuItem("删除选中的行"); MenuItem DeletRowMenu2 = DepartmentTable.AddMenuItem("删除选中的行"); DepartmentMenu.Click += DepartmentEventContent; StaffMenu.Click += StaffEventContent; DeletRowMenu1.Click += DeletRows1; DeletRowMenu2.Click += DeletRows2; DepartmentTable.dgMenu.Items.Add(DepartmentMenu); DepartmentTable.dgMenu.Items.Add(DeletRowMenu1); StaffTable.dgMenu.Items.Add(StaffMenu); StaffTable.dgMenu.Items.Add(DeletRowMenu2); }
public void Create_ValidData_StaffIDReturned() { //Assemble StaffModel staffModel = new StaffModel(); staffModel.name = "Bob"; //If created will be greater than 0, but we don't know exactly what it will be because deleting all records doesnt set the ID counter back to 0 int notCreated = 0; StaffTable staffTable = new StaffTable(); //Act int actual = staffTable.create(staffModel); //Assert Assert.AreNotEqual(notCreated, actual); }
public void Count_Created1Record_1() { //Assemble StaffModel staffModel = new StaffModel(); staffModel.name = "Bob"; int expected = 1; StaffTable staffTable = new StaffTable(); //Act int staffID = staffTable.create(staffModel); int actual = staffTable.count(); //Assert Assert.AreEqual(expected, actual); }
public void Delete_CreatedDeleteAndCount1Record_0() { //Assemble StaffModel staffModel = new StaffModel(); staffModel.name = "Bob"; int expected = 0; StaffTable staffTable = new StaffTable(); int staffID = staffTable.create(staffModel); //Act staffTable.delete(staffID); int actual = staffTable.count(); //Assert Assert.AreEqual(expected, actual); }
private void panelBusinessPeople_DoubleClick(object sender, EventArgs e) { if (!this.textBoxBusinessPeople.Visible) { this.labelBusinessPeople.Visible = false; this.textBoxBusinessPeople.Visible = true; } else { FormBaseStaff fbs = new FormBaseStaff(true); fbs.ShowDialog(); m_staffPkey = fbs.getSelectRecordPkey(); StaffTable record = Staff.getInctance().getStaffInfoFromPkey(m_staffPkey); this.textBoxBusinessPeople.Text = record.name; this.textBoxBusinessPeople.Visible = true; } }
// GET: StaffTables/Details/5 public ActionResult Details(int?id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffTable staffTable = db.StaffTables.Find(id); if (staffTable == null) { return(HttpNotFound()); } return(View(staffTable)); }