public bool GetFromElement(XElement xRelation, out RelationBetweenTwoPerson relation) { try { int firstID = Int32.Parse(xRelation.Attribute("firstPerson").Value); int secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value); Relatives relative = (Relatives)Enum.Parse(typeof(Relatives), xRelation.Attribute("relation").Value); PersonList personList = PersonList.GetPersonList(null); Person fPerson; Person sPerson; if ((personList.GetPersonFromID(firstID, out fPerson)) && (personList.GetPersonFromID(secondID, out sPerson))) { relation = new RelationBetweenTwoPerson(fPerson, sPerson, relative); return(true); } else { relation = null; return(false); } } catch { relation = null; return(false); } }
public Person(string name, string RelativeName, string birthday, string type) : this(name) { this.Relatives = new List <Relative>(); Relative parent = new Relative(RelativeName, birthday, type); Relatives.Add(parent); }
public bool GetFromElement(XElement xTable, out RelationsTable table) { table = RelationsTable.GetTable(); table.Clear(); try { foreach (XElement xRelation in xTable.Elements("relation")) { int firstID = Int32.Parse(xRelation.Attribute("firstPerson").Value); int secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value); Relatives relation = (Relatives)Enum.Parse(typeof(Relatives), xRelation.Attribute("relation").Value); PersonList personList = PersonList.GetPersonList(null); Person fPerson; Person sPerson; if ((personList.GetPersonFromID(firstID, out fPerson)) && (personList.GetPersonFromID(secondID, out sPerson))) { table.SetRelationBetweenPersons(fPerson, sPerson, relation); } } return(true); } catch { return(false); } }
public static Relatives GetByClient(int id) { Relatives rel = null; SqlConnection con; using (SqlDataReader dr = DataManager.GetDataReader("ESystem_RelativeGetByClient", out con, DataManager.CreateParameter("@id", SqlDbType.Int, id))) { if (dr.HasRows) { while (dr.Read()) { rel = FillDataRecord(dr); } } else { throw new Exception("No Data"); } con.Close(); } return(rel); }
public static Relatives GetItem(int id) { Relatives rel = RelativesDAL.GetByClient(id); Client cl = ClientBLL.GetItem(rel.CLientRelId); rel.ClientRelName = cl.FullName; rel.CLientRelId = cl.CLientId; return(rel); }
// xóa giáo viên theo ID public int DeleteRelatives(Relatives relatives) { string sql = string.Format("delete from THANNHAN where MaTN = @a1"); List <SqlParameter> p = new List <SqlParameter>(); p.Add(new SqlParameter("@a1", relatives.MaTN)); return(DATA.Instance.WriteData(sql, p)); }
public static int Insert(Relatives rel) { object o = DataManager.ExecuteScalar("ESystem_RelativeInsert", DataManager.CreateParameter("@ClientId", SqlDbType.Int, rel.ClientId), DataManager.CreateParameter("@CLientRelId", SqlDbType.Int, rel.CLientRelId), DataManager.CreateParameter("@RelaionName", SqlDbType.NVarChar, rel.RelationName)); return(Convert.ToInt32(o)); }
public bool Equals(FamilyInfo other) { if (other == null) { return(false); } return(ParentFamilyStatus == other.ParentFamilyStatus && Relatives.SequenceEqual(other.Relatives)); }
// thêm mới giáo viên public int RepearRelatives(Relatives relatives) { string sql = string.Format("UPDATE dbo.THANNHAN SET TenTN = @a1,CongViec = @a2,SDT =@a3,QuanHe = @a4 WHERE MaTN = @a5"); List <SqlParameter> p = new List <SqlParameter>(); p.Add(new SqlParameter("@a1", relatives.TenTN)); p.Add(new SqlParameter("@a2", relatives.CongViec)); p.Add(new SqlParameter("@a3", relatives.SDT)); p.Add(new SqlParameter("@a4", relatives.QuanHe)); p.Add(new SqlParameter("@a5", relatives.MaTN)); return(DATA.Instance.WriteData(sql, p)); }
private void SaveRelationButton_Click(object sender, RoutedEventArgs e) { if (RelationTableDataGrid.SelectedIndex != -1) { Relatives relative; if (Relatives.TryParse(RelationComboBox.SelectedValue.ToString(), out relative)) { RelationsTable.GetTable().SetRelationBetweenPersons(_currentRelation.FirstPerson, _currentRelation.SecondPerson, relative); RefreshTable(); } } }
public EditRelatives(Relatives relatives) { InitializeComponent(); // cập nhật thông tin hiển thị values.Add(relatives.MaTN.ToString()); values.Add(relatives.TenTN); values.Add(relatives.CongViec); values.Add(relatives.SDT); values.Add(relatives.QuanHe); // load dữ liệu vào các textbox Load_Data(values); }
public int DeleteRelatives(string IDRelatives) { try { Relatives relatives = new Relatives(); relatives.MaTN = int.Parse(IDRelatives); //Xử lý dữ liệu return(relativesDAO.DeleteRelatives(relatives)); } catch (Exception ex) { throw ex; } }
private void BindData() { try { Client client = ClientBLL.GetItem(Convert.ToInt32(Request.QueryString["id"])); int id = Convert.ToInt32(Request.QueryString["id"]); if (client.HasArelation == HasRelations.yes) { Application["flag"] = "true"; rdlst.SelectedIndex = 0; drpClients.DataSource = ClientBLL.GetList(); drpClients.DataTextField = "FullName"; drpClients.DataValueField = "ClientId"; drpClients.DataBind(); Relatives rel = RelativesBLL.GetItem(id); txtRelName.Text = rel.RelationName; drpClients.SelectedItem.Text = rel.ClientRelName; } else { Application["flag"] = "false"; pnlRelationData.Visible = false; rdlst.SelectedIndex = 1; } txtFName.Text = client.FirstName; txtMiddleName.Text = client.MiddleName; txtSurrName.Text = client.SurrName; txtCity.Text = client.City; drpCountry.SelectedItem.Text = client.Country; txtAdress.Text = client.Address; txtTelephone.Text = client.Telephone; txtMob.Text = client.Mob; txtDateOf.Text = client.DateOfBirth.ToString("dd/MM/yyyy"); drpGender.SelectedItem.Text = client.Gender; txtNotes.Text = client.Notes; } catch (Exception ex) { this.ShowHelperMessage("Error", ex.Message, HelperNotify.NotificationType.error); } }
public Task <Result <Guid> > Add(CreateRelativeModel model) => Result <Guid> .TryAsync(async() => { var relative = new Relatives { Id = Guid.NewGuid(), UserId = generalDataService.User.Id, Firstname = model.Firstname, Lastname = model.Lastname, DateOfBirth = model.DateOfBirth, RelationType = model.RelationType, SinNumber = model.SinNumber }; _repository.Add(relative); await _repository.CommitAsync(); return(Result <Guid> .Successful(relative.Id)); });
private static Relatives FillDataRecord(IDataRecord myDataRecord) { Relatives relative = new Relatives(); relative.RelativeId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("RelativeId")); relative.ClientId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("ClientId")); if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("CLientRelId"))) { relative.CLientRelId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("CLientRelId")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("RelaionName"))) { relative.RelationName = myDataRecord.GetString(myDataRecord.GetOrdinal("RelaionName")); } return(relative); }
/// <summary> /// Thêm thông tin cho thân nhân /// </summary> /// <param name="TenTN"></param> /// <param name="CongViec"></param> /// <param name="SDT"></param> /// <param name="QuanHe"></param> /// <returns></returns> public int InsertRelatives(List <string> values) { // tạo ra biến ghi nhận lỗi string strError = ""; try { Relatives relatives = new Relatives(); relatives.MaHS = int.Parse(values[0]); relatives.TenTN = values[1]; relatives.CongViec = values[2]; relatives.SDT = values[3]; relatives.QuanHe = values[4]; //Xử lý dữ liệu return(relativesDAO.InsertRelatives(relatives)); } catch (Exception ex) { MessageBox.Show("Lỗi không xác định", "WARNING InsertRelatives"); return(0); } }
/// <summary> /// /// </summary> /// <param name="MaTN"></param> /// <param name="TenTN"></param> /// <param name="CongViec"></param> /// <param name="SDT"></param> /// <param name="QuanHe"></param> /// <returns></returns> public int RepearRelatives(List <string> values) { // tạo ra biến ghi nhận lỗi string strError = ""; try { //Xử lý chính(nghiệp vụ) Relatives relatives = new Relatives(); relatives.TenTN = values[1]; relatives.CongViec = values[2]; relatives.SDT = values[3]; relatives.QuanHe = values[4]; strError = "Text not number1"; relatives.MaTN = int.Parse(values[0]); //Xử lý dữ liệu return(relativesDAO.RepearRelatives(relatives)); } catch (Exception ex) { switch (strError) { case "Text not number1": { MessageBox.Show("Chương trình không nhận kí tự chữ .@0", "WARNING RepearRelatives"); break; } default: { break; } } return(0); } }
// GET: Characters/Character/5 public async Task <IActionResult> Character(int?id) { List <Relatives> relatives = new List <Relatives>(); if (id == null) { return(NotFound()); } var character = await _context.Characters .Include(c => c.Location) .Include(c => c.World) .FirstOrDefaultAsync(m => m.CharacterID == id); if (character == null) { return(NotFound()); } List <Relationship> relate = await _context.Relationships.Where(r => r.Character1ID == id).ToListAsync(); foreach (var r in relate) { Relatives temp = new Relatives(); Character c = new Character(); RelationshipType t = new RelationshipType(); c = await _context.Characters.FirstOrDefaultAsync(m => m.CharacterID == r.Character2ID); t = await _context.RelationshipTypes.FirstOrDefaultAsync(m => m.RelationshipTypeID == r.RelationshipTypeID); temp.Relative = c; temp.Relation = t; temp.ID = r.RelationshipID; relatives.Add(temp); } ViewBag.relations = relatives; return(View(character)); }
private void dtgvRelatives_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { // F4 : Sửa if (e.KeyCode == Keys.F4) { DataGridViewRow row = dtgvRelatives.SelectedCells[0].OwningRow; Relatives relatives = new Relatives(); relatives.MaTN = int.Parse(row.Cells["MaTN"].Value.ToString()); relatives.TenTN = row.Cells["TenTN"].Value.ToString(); relatives.CongViec = row.Cells["CongViec"].Value.ToString(); relatives.SDT = row.Cells["SDT"].Value.ToString(); relatives.QuanHe = row.Cells["QuanHe"].Value.ToString(); EditRelatives editRelatives = new EditRelatives(relatives); editRelatives.ShowDialog(); // load lại dữ liệu hiển thị Load_Relatives(); } // F8 : xóa else if (e.KeyCode == Keys.F8) { //values[0] : mã thân nhân DialogResult dialogResult = MessageBox.Show("Bạn có chắc muốn thực hiện việc này", "WARNING", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { DataGridViewRow row = dtgvRelatives.SelectedCells[0].OwningRow; values[0] = row.Cells["MaTN"].Value.ToString(); // gọi đến BUS để xử lý (thêm vào CSDL) relativesBUS.DeleteRelatives(values[0]); MessageBox.Show("Delete complete."); // load lại dữ liệu hiển thị Load_Relatives(); } } }
public static ClientCase GetItem(int id) { ClientCase clientCase = ClientCaseDAL.GetItem(id); Client client = ClientBLL.GetItem(clientCase.ClientId); Prescription presc = PrescriptionBLL.GetByCase(clientCase.CaseId); try { Relatives rel = RelativesBLL.GetItem(clientCase.ClientId); clientCase.ClientRelName = rel.ClientRelName; } catch (Exception) { } clientCase.FullName = client.FullName; clientCase.Mob = client.Mob; clientCase.Gender = client.Gender; clientCase.PrescriptionStatus = presc.Status; //Prescription return(clientCase); }
public override string ToString() { StringBuilder pokes = new StringBuilder(); foreach (var pokemon in Pokemons) { pokes.AppendFormat($"\n{pokemon.Name} {pokemon.Type}"); } StringBuilder parenti = new StringBuilder(); foreach (var moruk in Relatives.Where(a => a.Type == "parent")) { parenti.AppendFormat($"\n{moruk.Name} {moruk.Birthday}"); } StringBuilder childri = new StringBuilder(); foreach (var child in Relatives.Where(a => a.Type == "child")) { childri.AppendFormat($"\n{child.Name} {child.Birthday}"); } string pokemoni = pokes.ToString(); var result = $"{this.Name}"; result = string.Concat(result, Environment.NewLine); result = string.Concat(result, this.CompanyName == null ? "Company:" + Environment.NewLine: $"Company: {this.CompanyName}"); result = string.Concat(result, this.CarName == null ? "Car:" + Environment.NewLine : $"Car: {this.CarName}"); result = string.Concat(result, this.Pokemons.Count == 0 ? "Pokemon:" : $"Pokemon: {pokemoni}"); result = string.Concat(result, Environment.NewLine); result = string.Concat(result, this.Pokemons.Count == 0 ? "Parents:" : $"Parents: {parenti}"); result = string.Concat(result, Environment.NewLine); result = string.Concat(result, this.Pokemons.Count == 0 ? "Children:" : $"Children: {childri}"); return(result); }
public Relatives GetOpositeRelative(Relatives relatives, Person secondPerson) { switch (relatives) { case Relatives.aunt: return((secondPerson.Gender == Genders.Male) ? Relatives.nephew : Relatives.niece); break; case Relatives.uncle: return((secondPerson.Gender == Genders.Male) ? Relatives.nephew : Relatives.niece); break; case Relatives.grandfather: return((secondPerson.Gender == Genders.Male) ? Relatives.grandson : Relatives.granddaughter); break; case Relatives.grandmother: return((secondPerson.Gender == Genders.Male) ? Relatives.grandson : Relatives.granddaughter); break; case Relatives.brother: return((secondPerson.Gender == Genders.Male) ? Relatives.brother : Relatives.sister); break; case Relatives.sister: return((secondPerson.Gender == Genders.Male) ? Relatives.brother : Relatives.sister); break; case Relatives.daughter: return((secondPerson.Gender == Genders.Male) ? Relatives.father : Relatives.mother); break; case Relatives.son: return((secondPerson.Gender == Genders.Male) ? Relatives.father : Relatives.mother); break; case Relatives.father: return((secondPerson.Gender == Genders.Male) ? Relatives.son : Relatives.daughter); break; case Relatives.mother: return((secondPerson.Gender == Genders.Male) ? Relatives.son : Relatives.daughter); break; case Relatives.granddaughter: return((secondPerson.Gender == Genders.Male) ? Relatives.grandfather : Relatives.grandmother); break; case Relatives.grandson: return((secondPerson.Gender == Genders.Male) ? Relatives.grandfather : Relatives.grandmother); break; case Relatives.husband: return((secondPerson.Gender == Genders.Male) ? Relatives.husband : Relatives.wife); break; case Relatives.wife: return((secondPerson.Gender == Genders.Male) ? Relatives.husband : Relatives.wife); break; case Relatives.nephew: return((secondPerson.Gender == Genders.Male) ? Relatives.uncle : Relatives.aunt); break; case Relatives.niece: return((secondPerson.Gender == Genders.Male) ? Relatives.uncle : Relatives.aunt); break; case Relatives.NoRelative: return((secondPerson.Gender == Genders.Male) ? Relatives.NoRelative : Relatives.NoRelative); break; default: return(Relatives.NoRelative); } }
public bool SetRelationBetweenPersons(Person firstPerson, Person secondPerson, Relatives relation) { RelationBetweenTwoPerson tmp = GetRelationsBetweenPersons(firstPerson, secondPerson); try { if (tmp == null) { RelationBetweenTwoPerson newRelation = new RelationBetweenTwoPerson(firstPerson, secondPerson, relation); RelationBetweenTwoPerson newOppositeRelation = new RelationBetweenTwoPerson(secondPerson, firstPerson, GetOpositeRelative(relation, secondPerson)); _relationsList.Add(newRelation); _relationsList.Add(newOppositeRelation); return(true); } else { RelationBetweenTwoPerson relatives = _relationsList.Where <RelationBetweenTwoPerson>(x => (x.FirstPerson == firstPerson) && (x.SecondPerson == secondPerson)).Single <RelationBetweenTwoPerson>(); relatives.Relations = relation; RelationBetweenTwoPerson oppositeRelation = _relationsList.Where <RelationBetweenTwoPerson>(x => (x.FirstPerson == secondPerson) && (x.SecondPerson == firstPerson)).Single <RelationBetweenTwoPerson>(); oppositeRelation.Relations = GetOpositeRelative(relation, secondPerson); return(true); } } catch (Exception) { return(false); } }
public RelationBetweenTwoPerson(Person firstPerson, Person secondPerson, Relatives relations) { FirstPerson = firstPerson; SecondPerson = secondPerson; Relations = relations; }
public static bool Delete(Relatives relative) { return(RelativesDAL.Delete(relative.RelativeId)); }
public static int Update(Relatives relative) { relative.RelativeId = RelativesDAL.Update(relative); return(relative.RelativeId); }
public static int Insert(Relatives relative) { relative.RelativeId = RelativesDAL.Insert(relative); return(relative.RelativeId); }
protected void btnSave_Click(object sender, EventArgs e) { try { Client client = new Client(); #region CLient Data //Load the data into the object //Re Initialize int id = Convert.ToInt32(Request.QueryString["id"]); client.CLientId = id; client.FirstName = txtFName.Text; client.MiddleName = txtMiddleName.Text; client.SurrName = txtSurrName.Text; client.City = txtCity.Text; client.Country = drpCountry.SelectedItem.Text; client.Address = txtAdress.Text; client.Telephone = txtTelephone.Text; client.Mob = txtMob.Text; client.DateOfBirth = Convert.ToDateTime(txtDateOf.Text); client.Gender = drpGender.SelectedItem.Text; client.Notes = txtNotes.Text; client.CreatedBy = ClientBLL.GetItem(id).CreatedBy; client.CreationDate = ClientBLL.GetItem(id).CreationDate; client.IsActive = IsActive.Active; #endregion #region Relation Data if (Application["flag"] == "true") { if (rdlst.SelectedIndex == 0) { Relatives relative = new Relatives(); relative.ClientId = Convert.ToInt32(Request.QueryString["id"]); relative.CLientRelId = Convert.ToInt32(drpClients.SelectedItem.Value); relative.RelationName = txtRelName.Text; RelativesBLL.Update(relative); client.HasArelation = HasRelations.yes; clientID = ClientBLL.Update(client); } } else { if (rdlst.SelectedIndex == 0) { Relatives rel = new Relatives(); rel.ClientId = Convert.ToInt32(Request.QueryString["id"]); rel.CLientRelId = Convert.ToInt32(drpClients.SelectedItem.Value); rel.RelationName = txtRelName.Text; RelativesBLL.Insert(rel); client.HasArelation = HasRelations.yes; clientID = ClientBLL.Update(client); } else { try { List <Relatives> rel = RelativesBLL.GetByClient(Convert.ToInt32(Request.QueryString["id"])); foreach (Relatives item in rel) { RelativesBLL.Delete(item); } client.HasArelation = HasRelations.no; } catch (Exception) { } clientID = ClientBLL.Update(client); } } #endregion //session fore firing the jquery notify string message = "CLient has been Updated"; Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } catch (Exception ex) { string message = ex.Message.Replace("\n", " "); Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } }
void Start() { description = GetComponentInChildren <Text>(); relatives_subject = subjectTransform.GetComponent <Relatives>(); }
public override int GetHashCode() { return(ParentFamilyStatus.GetHashCode() ^ Relatives.GetHashCode()); }