/////////Methods///////// /// <summary> /// Adds each staff member to their respective performance list /// </summary> /// <param name="researchers">List of all researchers</param> public void Generate(List <Model.Researcher> researchers) { foreach (Model.Researcher a in researchers) { if (a.Type == "Staff") { Model.Staff i = (Model.Staff)a; i.Publications = new List <Model.Publication>(pubController.LoadPublicationsFor(i)); float performance = i.Performance(); if (performance <= 70f) { poor.Add(i); } else if (performance > 70f && performance < 110f) { below.Add(i); } else if (performance >= 100f && performance < 200f) { meeting.Add(i); } else if (performance >= 200f) { star.Add(i); } } } }
// Fetch list of students staff member is or has ever supervised // from database. public static List <Model.Student> fetchSupervisions(Model.Staff s) { MySqlCommand cmd = new MySqlCommand("SELECT * FROM researcher" + "WHERE supervisor_id=?id", conn); cmd.Parameters.AddWithValue("id", s.Id); MySqlDataReader rdr = null; rdr = cmd.ExecuteReader(); List <Model.Student> supervisions = new List <Model.Student>(); while (rdr.Read()) { supervisions.Add(new Model.Student { Id = rdr.GetInt32(rdr.GetOrdinal("id")), FirstName = rdr.GetString(rdr.GetOrdinal("given_name")), LastName = rdr.GetString(rdr.GetOrdinal("family_name")), Title = rdr.GetString(rdr.GetOrdinal("title")), Email = rdr.GetString(rdr.GetOrdinal("title")), Photo = new Uri(rdr.GetString(rdr.GetOrdinal("photo"))), StartInstitution = rdr.GetDateTime(rdr.GetOrdinal("utas_start")), StartCurrentJob = rdr.GetDateTime(rdr.GetOrdinal("current_start")), Degree = rdr.GetString(rdr.GetOrdinal("degree")), SupervisorId = rdr.GetInt32(rdr.GetOrdinal("supervisor_id")) }); } return(supervisions); }
public void InsertStaff(Model.Staff staff) { using (var context = SCMSEntities.Define()) { context.Staffs.Add(staff); context.SaveChanges(); } }
public void UpdateStaff(Model.Staff staff) { using (var context = SCMSEntities.Define()) { context.Staffs.Attach(staff); ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(staff, System.Data.EntityState.Modified); context.SaveChanges(); } }
private void btSearchStaff_Click(object sender, EventArgs e) { string information = ""; switch (combStaff.Text.Trim()) { case "工号": information = "staID"; break; case "姓名": information = "staName"; break; case "性别": information = "staSex"; break; case "年龄": information = "staAge"; break; default: break; } Maticsoft.BLL.Staff sta = new BLL.Staff(); string string1 = string.Format("{0} = '{1}'", information, tbStaff.Text.Trim()); if (information == "staID") { Model.Staff smodel = new Model.Staff(); smodel = sta.GetModel1(string1); if (smodel.staID == "" || smodel.staID == null) { MessageBox.Show("查无此人"); } else { SeekStaff see = new Hotel.SeekStaff(smodel); see.ShowDialog(this); } } else { DataSet ds = new DataSet(); ds = sta.GetList(string1); dgvManager.DataSource = ds.Tables[0]; ds.Tables[0].Columns["staID"].ColumnName = "员工工号"; ds.Tables[0].Columns["staName"].ColumnName = "姓名"; ds.Tables[0].Columns["staSex"].ColumnName = "性别"; ds.Tables[0].Columns["staAge"].ColumnName = "年龄"; dgvStaff.AllowUserToAddRows = false; dgvStaff.SelectionMode = DataGridViewSelectionMode.FullRowSelect; } }
} //Current Window //////////Methods////////////// /// <summary> /// Adds the details of a given researcher to the view /// </summary> /// <param name="researcher">The researhcer details being added to the screen</param> public void SetDetails(Model.Researcher researcher) { //add data to text boxes ResearcherDetailsView_Name_Value.Text = researcher.GivenName + " " + researcher.FamilyName; ResearcherDetailsView_Title_Value.Text = researcher.Title; ResearcherDetailsView_Unit_Value.Text = researcher.School; ResearcherDetailsView_Campus_Value.Text = researcher.Campus; ResearcherDetailsView_Email_Value.Text = researcher.Email; ResearcherDetailsView_CurrentJob_Value.Text = researcher.CurrentJobTitle(); ResearcherDetailsView_ComInst_Value.Text = researcher.GetEarliestJob().Start.ToString("dd/MM/yyyy"); ResearcherDetailsView_ComPos_Value.Text = researcher.GetCurrentJob().Start.ToString("dd/MM/yyyy"); ResearcherDetailsView_Tenure_Value.Text = researcher.Tenure().ToString() + " years"; ResearcherDetailsView_Publications_Value.Text = researcher.PublicationsCount().ToString(); ResearcherDetailsView_ProfileImage.Source = new BitmapImage(researcher.Photo); PublicationsListView.PublicationsListView_Display_Box.ItemsSource = new ObservableCollection <Model.Publication>(researcher.Publications); //Staff only details if (researcher.Type == "Staff") { int count = 0; //Supervised students count Model.Staff staffCast = (Model.Staff)researcher; //Current researcher object //Get count of supervised students foreach (Model.Student i in staffCast.Supervisions) { count++; } ResearcherDetailsView_3YAv_Value.Text = staffCast.ThreeYearAverage().ToString(); ResearcherDetailsView_Supervisions_Value.Text = count.ToString(); Window.SupervisionsListView.SupervisionsListView_Display_Box.ItemsSource = new ObservableCollection <Model.Researcher>(staffCast.Supervisions as List <Model.Student>); ResearcherDetailsView_Performance_Value.Text = staffCast.Performance().ToString() + "%"; ResearcherDetailsView_PrevPos_Data.ItemsSource = researcher.Positions; //Reset any set student details ResearcherDetailsView_Degree_Value.Text = ""; ResearcherDetailsView_Supervisor_Value.Text = ""; } //Students only details else { Model.Student stundetCast = (Model.Student)researcher; //Current researcher object ResearcherDetailsView_Degree_Value.Text = stundetCast.Degree; ResearcherDetailsView_Supervisor_Value.Text = stundetCast.SupervisorName; //Reset any set staff details ResearcherDetailsView_3YAv_Value.Text = ""; ResearcherDetailsView_Supervisions_Value.Text = ""; Window.SupervisionsListView.SupervisionsListView_Display_Box.ItemsSource = new ObservableCollection <Model.Researcher>(); ResearcherDetailsView_Performance_Value.Text = ""; ResearcherDetailsView_PrevPos_Data.ItemsSource = null; } }
public Staff(int trackIndex, Model.Staff staff, BarRendererFactory factory) { BarRenderers = new FastList <BarRendererBase>(); TrackIndex = trackIndex; ModelStaff = staff; _factory = factory; TopSpacing = 15; BottomSpacing = 5; StaveTop = 0; StaveBottom = 0; }
public Staff(int trackIndex, Model.Staff staff, BarRendererFactory factory, FastDictionary <string, object> settings) { BarRenderers = new FastList <BarRendererBase>(); TrackIndex = trackIndex; ModelStaff = staff; _factory = factory; _settings = settings; TopSpacing = 15; BottomSpacing = 5; StaveTop = 0; StaveBottom = 0; }
public Staff(int trackIndex, Model.Staff staff, BarRendererFactory factory) { BarRenderers = new FastList <BarRendererBase>(); TrackIndex = trackIndex; ModelStaff = staff; _factory = factory; TopSpacing = 20; BottomSpacing = 5; StaveTop = 0; StaveBottom = 0; _sharedLayoutData = new FastDictionary <string, object>(); }
public Staff(Model.Staff staff, string staveId, BarRendererFactory factory, FastDictionary <string, object> settings) { BarRenderers = new FastList <BarRendererBase>(); _barRendererLookup = new FastDictionary <int, BarRendererBase>(); ModelStaff = staff; StaveId = staveId; _factory = factory; _settings = settings; TopSpacing = 10; BottomSpacing = 10; StaveTop = 0; StaveBottom = 0; }
public static Staff ToEntity(this SystemUserModel model, Model.Staff staff) { staff = staff ?? new Staff { Id = Guid.NewGuid() }; staff.DesignationId = model.SelectedDesignationId; staff.CountrySubOfficeId = model.SelectedCountrySubOfficeId; if (model.FinanceLimitId.HasValue) { staff.FinanceLimitId = (Guid)model.FinanceLimitId; } return(staff); }
public bool SaveNewStaff(Model.Staff aStaff) { bool condition = false; aStaffGateway = new StaffGateway(); condition = aStaffGateway.SaveNewStaff(aStaff); if (condition) { return(true); } else { return(false); } }
private void tbID_TextChanged(object sender, EventArgs e) { Maticsoft.BLL.Staff sta = new BLL.Staff(); string string1 = string.Format("staID = '{0}'", tbID.Text.Trim()); if (sta.GetRecordCount(string1) == 1) { Model.Staff stamodel = new Model.Staff(); nudAge.Value = sta.GetModel1(string1).staAge; } else { nudAge.Value = 18; } }
private static String AuthName(SCMSEntities db, Model.PurchaseOrder POentity, String authourisation, Model.Staff s) { authourisation += "<tr><td class=\"gridheader\">Name:</td><td>"; authourisation += s.Person.FirstName + " " + s.Person.OtherNames; authourisation += "</td><td>"; //if ((bool)POentity.IsReviewed && POentity.ReviewedBy != null) //{ // Model.Staff r = db.Staffs.FirstOrDefault(p => p.Id == POentity.ReviewedBy); // authourisation += r.Person.FirstName + " " + r.Person.OtherNames; //} authourisation += "</td><td>"; if ((bool)POentity.IsApproved && POentity.ApprovedBy != null) { Model.Staff auth = db.Staffs.FirstOrDefault(p => p.Id == POentity.ApprovedBy); authourisation += auth.Person.FirstName + " " + auth.Person.OtherNames; } authourisation += "</td><tr>"; return(authourisation); }
private static String AuthDate(SCMSEntities db, Model.PurchaseOrder POentity, String authourisation) { authourisation += "<tr><td class=\"gridheader\">Date:</td><td>"; authourisation += POentity.PreparedOn.Value.ToString("dd/MM/yyyy h:mm tt"); authourisation += "</td><td>"; //if ((bool)POentity.IsReviewed && POentity.ReviewedBy != null) //{ // Model.Staff r = db.Staffs.FirstOrDefault(p => p.Id == POentity.ReviewedBy); // authourisation += POentity.ReviewedOn.Value.ToString("dd/MM/yyyy h:mm tt"); //} authourisation += "</td><td>"; if ((bool)POentity.IsApproved && POentity.ApprovedBy != null) { Model.Staff auth = db.Staffs.FirstOrDefault(p => p.Id == POentity.ApprovedBy); authourisation += POentity.ApprovedOn.Value.ToString(Constants.DATETIME_FORMAT); } authourisation += "</td><tr>"; return(authourisation); }
protected void Approve_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); foreach (var item in PendingStaffsListView.Items) { var toggle = item.FindControl("togglebox") as CheckBox; if (toggle.Checked) { var idField = item.FindControl("ID") as HiddenField; int id = int.Parse(idField.Value); staffLogic.verifyStaff(id); Model.Staff staff = staffLogic.getStaff(id); manager.AddToRole(staff.UserId, staff.Title); } } }
public bool SaveNewStaff(Model.Staff aStaff) { connection.Open(); string query = string.Format("INSERT INTO NewStaffTable values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", aStaff.StaffType.StaffTypeId, aStaff.StaffDesignation.StaffDesignationId, aStaff.Name, aStaff.Address, aStaff.IdCardNumber, aStaff.PhoneNumber, aStaff.Email, aStaff.Note, aStaff.FatherName, aStaff.City, aStaff.Balance); command = new SqlCommand(query, connection); int affectedRows = command.ExecuteNonQuery(); connection.Close(); if (affectedRows > 0) { return(true); } else { return(false); } }
protected void RegisterBtn_Click(object sender, EventArgs e) { // int x= int.Parse(ProcessDD.SelectedItem.Value); var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { Model.Staff staff = new Model.Staff { FName = FName.Text, LName = LName.Text, Email = Email.Text, ProcessID = int.Parse(ProcessDD.SelectedItem.Value), Title = TitleDD.SelectedItem.Text, role_id = TitleDD.SelectedItem.Value, PhoneNumber = Phone.Text, UserId = user.Id, }; if (sl.RegisterStaff(staff) > 0) { //manager.AddToRole(user.Id, staff.Title); signInManager.SignIn(user, isPersistent: true, rememberBrowser: true); //Server.TransferRequest("~/default.aspx"); IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
private String AuthSignature(SCMSEntities db, Model.PurchaseOrder POentity, String authourisation, Model.Staff s) { authourisation += "<tr><td class=\"gridheader\">Signature:</td><td>"; if (s.Person.SignatureImage != null) { authourisation += string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 100px;\" />", "data:image/png;base64," + Convert.ToBase64String(s.Person.SignatureImage)); } authourisation += "</td><td>"; Model.Staff r = db.Staffs.FirstOrDefault(p => p.Id == POentity.ApprovedBy); if ((bool)POentity.IsApproved && POentity.ApprovedBy != null && r.Person.SignatureImage != null) { authourisation += string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 100px;\" />", "data:image/png;base64," + Convert.ToBase64String(r.Person.SignatureImage)); } authourisation += "</td><td>"; Model.Staff auth = db.Staffs.FirstOrDefault(p => p.Id == POentity.ApprovedBy); if ((bool)POentity.IsApproved && POentity.ApprovedBy != null && auth.Person.SignatureImage != null) { authourisation += string.Format("<img src=\"{0}\" alt=\"\" style=\"max-width: 100px;\" />", "data:image/png;base64," + Convert.ToBase64String(s.Person.SignatureImage)); } authourisation += "</td><tr>"; return(authourisation); }
private void btConfirm_Click(object sender, EventArgs e) { if (tbStaffID.Text.Trim() == "" || tbStaffName.Text.Trim() == "" || cbStaffSex.Text == "" || nupStaffAge.Value.ToString() == "" || pbPhoto.Image == null) { MessageBox.Show("输入信息不完整!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); flag = 1; } if (flag == 0) { Maticsoft.BLL.Staff sta = new BLL.Staff(); Model.Staff stamodel = new Model.Staff(); string str1 = string.Format("staID = '{0}'", tbStaffID.Text.Trim()); if (sta.GetRecordCount(str1) > 0) { MessageBox.Show("当前工号已存在!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { stamodel.staID = tbStaffID.Text.Trim(); stamodel.staName = tbStaffName.Text.Trim(); stamodel.staSex = cbStaffSex.Text.Trim(); stamodel.staAge = Convert.ToInt32(nupStaffAge.Value); stamodel.staPhoto = mybyte; if (sta.Add(stamodel) == true) { MessageBox.Show("添加成功!"); ((Main_Admin)this.Owner).StaffLoad(); this.Close(); } else { MessageBox.Show("添加失败!"); } } } }
private void btConfirm_Click(object sender, EventArgs e) { if (tbID.Text.Trim() == "") { MessageBox.Show("输入信息不完整!", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); flag = 1; } if (flag == 0) { Maticsoft.BLL.Staff sta = new BLL.Staff(); string string1 = string.Format("staID = '{0}'", tbID.Text.Trim()); if (sta.GetRecordCount(string1) == 1) { Model.Staff stamodel = new Model.Staff(); stamodel.staID = tbID.Text.Trim(); stamodel.staName = tbName.Text.Trim(); stamodel.staSex = cbSex.Text.Trim(); stamodel.staAge = Convert.ToInt32(nudAge.Value); stamodel.staPhoto = mybyte; if (sta.Update(stamodel) == true) { MessageBox.Show("修改成功!"); ((Main_Admin)this.Owner).StaffLoad(); this.Close(); } else { MessageBox.Show("修改失败!"); } } else { MessageBox.Show("不存在此员工!", "修改出错", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public SeekStaff(Model.Staff smo) { smodel = smo; InitializeComponent(); }
// // GET: /Reports/PO/ public ActionResult Index(Guid POid) { Dictionary <String, String> data = new Dictionary <string, string>(); using (var db = new SCMSEntities()) { Model.PurchaseOrder POentity = db.PurchaseOrders.FirstOrDefault(p => p.Id == POid); string taNumber = "Single Quote"; data.Add("{DATE}", POentity.PODate.ToString("dd/MM/yyyy")); data.Add("{PONo}", POentity.RefNumber); data.Add("{TANo}", taNumber); data.Add("{ORNo}", POentity.OrderRequest.RefNumber); data.Add("{PAYMENT-TERM}", POentity.PaymentTerm.Description); data.Add("{QUOTATION-REF}", POentity.QuotationRef); data.Add("{SHIPPINGTERM}", POentity.ShippingTerm.Description); data.Add("{PO-CURRENCY}", POentity.Currency.ShortName); data.Add("{TO-SUPPLIER}", POentity.Supplier.Name); data.Add("{DELIVER-ADDRESS}", POentity.Location.Name); data.Add("{DELIVERY-DATE}", POentity.LatestDeliveryDate.ToString("dd/MM/yyyy")); data.Add("{DRC-REMARKS}", POentity.Remarks); ICollection <PurchaseOrderItem> POItems = POentity.PurchaseOrderItems; int count = 1; String detailHtml = ""; foreach (PurchaseOrderItem poitem in POItems) { detailHtml += "<tr><td>" + count++ + "</td><td>"; detailHtml += poitem.OrderRequestItem.Item.Name; detailHtml += "</td><td>"; detailHtml += poitem.OrderRequestItem.Item.UnitOfMeasure.Code; detailHtml += "</td><td class='central'>"; detailHtml += poitem.Quantity.ToString("##,##0"); detailHtml += "</td><td class='central'>"; detailHtml += poitem.UnitPrice.ToString("#,##0.00"); detailHtml += "</td><td class='central'>"; detailHtml += poitem.TotalPrice.ToString("#,##0.00"); detailHtml += "</td><td>"; detailHtml += poitem.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber; detailHtml += "</td><td>"; detailHtml += db.ProjectBudgets.FirstOrDefault(p => p.Id == poitem.BudgetLineId).LineNumber; detailHtml += "</td><td>"; detailHtml += poitem.Remarks; detailHtml += "</td><tr>"; } while (count < 18) { detailHtml += "<tr><td>" + count++ + "</td><td>"; detailHtml += "</td><td>"; detailHtml += "</td><td class='central'>"; detailHtml += "</td><td class='central'>"; detailHtml += "</td><td class='central'>"; detailHtml += "</td><td>"; detailHtml += "</td><td>"; detailHtml += "</td><td>"; detailHtml += "</td><tr>"; } data.Add("{DETAILS}", detailHtml); data.Add("{CURRENCY}", POentity.Currency.ShortName); data.Add("{TOTAL-AMOUNT}", POentity.TotalAmount.Value.ToString("#,##0.00")); data.Add("{ADDITIONAL-REMARKS}", POentity.AdditionalRemarks); String authourisation = ""; Model.Staff s = db.Staffs.SingleOrDefault(p => p.Id == POentity.PreparedBy); authourisation = AuthName(db, POentity, authourisation, s); authourisation = AuthTitle(db, POentity, authourisation, s); authourisation = AuthDate(db, POentity, authourisation); authourisation = AuthSignature(db, POentity, authourisation, s); data.Add("{AUTHORISATION}", authourisation); data.Add("{PRO-FORMA}", string.Format("<input type=\"checkbox\" {0} />", POentity.ProformaRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{COMMERCIAL}", string.Format("<input type=\"checkbox\" {0} />", POentity.CommercialInvoiceRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{WB-AB}", string.Format("<input type=\"checkbox\" {0} />", POentity.WayBillRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{EPACKING}", string.Format("<input type=\"checkbox\" {0} />", POentity.PackingListRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{DELIVERYNN}", string.Format("<input type=\"checkbox\" {0} />", POentity.DeliveryNoteRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{MANUAL}", string.Format("<input type=\"checkbox\" {0} />", POentity.ManualsRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{CERTIFICATES}", string.Format("<input type=\"checkbox\" {0} />", POentity.CertificatesReqired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{OTHERS}", string.Format("<input type=\"checkbox\" {0} />", POentity.OtherRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{SPECIFY}", POentity.OtherSpecify); data.Add("{SHIPING-MARKS}", POentity.ShippingMarks); data.Add("{CONSIGNEE-ADDRESS}", POentity.ConsigneeAddress); data.Add("{CONSIGNEE-EMAIL}", POentity.ConsigneeEmail1); data.Add("{CONSIGNEE-EMANIL2}", POentity.ConsigneeEmail2); data.Add("{PRE-FINANCING}", string.Format("<input type=\"checkbox\" {0} />", POentity.PrefinancingGuaranteeRequired ? "value=\"\" checked=\"checked\"" : "")); data.Add("{PERCENTAGE-VALUE}", POentity.PFGPercentage != null ? POentity.PFGPercentage.Value.ToString("#,##0.00") + "%" : " "); } List <String> options = new List <string>(); options.Add(" --copies 3 "); Byte[] output = WkHtml2Pdf.CreateReport(data, "Purchase-Order.htm", options); return(File(output, "application/pdf", "PO_" + DateTime.Now.FormatDDMMMYYYYHHmm())); }
/// <summary> /// <para>Gets the details of a given researcher from the database</para> /// <para>Used to populate the Researcher Details View</para> /// </summary> /// <param name="id">The database ID number of the given researcher</param> /// <returns>A complete researcher object</returns> public static Model.Researcher FetchFullResearcherDetails(int id, List <Model.Researcher> researchers) { Model.Researcher researcher = null; //Researcher data object being returned MySqlDataReader rdr = null; //MySQL data reader GetConnection(); try { //Open database connection db_conn.Open(); //Create command, including database connection MySqlCommand cmd = new MySqlCommand("SELECT * FROM researcher WHERE id=?id", db_conn); cmd.Parameters.AddWithValue("id", id); //Get query results rdr = cmd.ExecuteReader(); //Add resulting object to Researcher object while (rdr.Read()) { switch (rdr.GetString(1)) { case "Student": Model.Student student = new Model.Student { ID = rdr.GetInt32(0), Type = rdr.GetString(1), GivenName = rdr.GetString(2), FamilyName = rdr.GetString(3), Title = rdr.GetString(4), School = rdr.GetString(5), Campus = rdr.GetString(6), Email = rdr.GetString(7), Photo = new Uri(rdr.GetString(8), UriKind.Absolute), Degree = rdr.GetString(9), Supervisor = rdr.GetInt32(10) }; student.Publications = new List <Model.Publication>(); student.Positions = new List <Model.Position>(); student.Positions.Add(new Model.Position { Level = Model.EmploymentLevel.Student, Start = rdr.GetDateTime(12), End = default(DateTime) }); //Get supervisor foreach (Model.Researcher i in researchers) { if (student.Supervisor == i.ID) { student.SupervisorName = i.FamilyName + ", " + i.GivenName + " (" + i.Title + ")"; } } researcher = student; break; case "Staff": //Get any supervisions the staff member List <Model.Student> supervisions = new List <Model.Student>(); foreach (Model.Researcher i in researchers) { if (i.Type == "Student") { Model.Student studentCast = (Model.Student)i; if (rdr.GetInt32(0) == studentCast.Supervisor) { supervisions.Add(studentCast); } } } researcher = new Model.Staff { ID = rdr.GetInt32(0), Type = rdr.GetString(1), GivenName = rdr.GetString(2), FamilyName = rdr.GetString(3), Title = rdr.GetString(4), School = rdr.GetString(5), Campus = rdr.GetString(6), Email = rdr.GetString(7), Photo = new Uri(rdr.GetString(8), UriKind.Absolute), Supervisions = new List <Model.Student>(supervisions), }; researcher.Publications = new List <Model.Publication>(); break; } } } //Catch any database errors catch (MySqlException e) { Console.WriteLine("Error: Cannot connect to database " + e); } //Close database connection and data reader finally { if (rdr != null) { rdr.Close(); } if (db_conn != null) { db_conn.Close(); } } //Get any previous positions that staff members have held if (researcher.Type != "Student") { researcher.Positions = FetchPositions(researcher.ID); } return(researcher); }
public int RegisterStaff(Model.Staff staff) { return(sta.InsertQuery(staff.FName, staff.LName, staff.PhoneNumber, staff.Email, staff.ProcessID, staff.UserId, false, staff.role_id)); }