Exemple #1
0
 public bool Equals(ComplaintAdded other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(AddedBy.Equals(other.AddedBy) && other.AddedAt.Equals(AddedAt) && Equals(other.Subject, Subject) && Equals(other.Body, Body) && Equals(other.Area, Area));
 }
        private void SaveRecord(object sender, bool e)
        {
            if (!e)
            {
                return;
            }


            var rec = new Complaint();

            //rec.ID = string.IsNullOrEmpty(controlNumberField.Text) ? Guid.NewGuid().ToString() : controlNumberField.Text;
            rec.Location       = locationField.Text.TrimStart(' ').TrimEnd(' ');
            rec.DateHappened   = dtIncident.Value;
            rec.DateIssued     = DateTime.Now;
            rec.SettlementDate = dtSettlement.Value;
            rec.Narrative      = narrativeField.Text;
            rec.Status         = ComplaintStatus.Pending.ToString();

            /// saving names in comps and resps
            //for (int i = 0; i < dgvComplainants.RowCount; i++)
            //{
            //    if (dgvComplainants.Rows[i].Cells[0].Value != null)
            //    {
            //        ///get the string of the id column
            //        string idString = dgvComplainants.Rows[i].Cells[1].Value.ToString();
            //        //if (!string.IsNullOrEmpty(idString))
            //        //    rec.CompNames += dgvComplainants.Rows[i].Cells[1].Value.ToString() + (i == dgvComplainants.RowCount - 2 ? "" : ",");
            //        Citizen c;
            //        if (CitizenExtensions.CitizenById(idString, out c))
            //            rec.CompNames += dgvComplainants.Rows[i].Cells[1].Value.ToString() + (i == dgvComplainants.RowCount - 2 ? "" : ",");

            //        else
            //            rec.CompNames += dgvComplainants.Rows[i].Cells[0].Value.ToString() + (i == dgvComplainants.RowCount - 2 ? "" : ",");
            //    }
            //}

            //for (int i = 0; i < dgvRespondents.RowCount; i++)
            //{
            //    if (dgvRespondents.Rows[i].Cells[0].Value != null)
            //    {
            //        ///get the string of the id column
            //        string idString = dgvRespondents.Rows[i].Cells[1].Value.ToString();
            //        Citizen c;
            //        if (CitizenExtensions.CitizenById(idString, out c))
            //            rec.RespNames += dgvRespondents.Rows[i].Cells[1].Value.ToString() + (i == dgvRespondents.RowCount - 2 ? "" : ",");

            //        else
            //            rec.RespNames += dgvRespondents.Rows[i].Cells[0].Value.ToString() + (i == dgvRespondents.RowCount - 2 ? "" : ",");

            //    }
            //}
            //for (int i = 0; i < dgvComplainants.RowCount; i++)
            //{
            //    if (dgvComplainants.Rows[i].Cells[0].Value != null)
            //        rec.CompNames += dgvComplainants.Rows[i].Cells[0].Value.ToString() + (i == dgvComplainants.RowCount - 2 ? "" : ",");
            //}
            //for (int i = 0; i < dgvRespondents.RowCount; i++)
            //{
            //    if (dgvRespondents.Rows[i].Cells[0].Value != null)
            //        rec.RespNames += dgvRespondents.Rows[i].Cells[0].Value.ToString() + (i == dgvRespondents.RowCount - 2 ? "" : ",");
            //}
            ///end if



            using (var ent = new EBarangayEntities())
            {
                ent.Complaints.Add(rec);
                ent.SaveChanges();
            }

            connectComplaintToCitizen(rec, dgvComplainants);
            connectComplaintToCitizen(rec, dgvRespondents);

            ComplaintAdded?.Invoke(this, new EventArgs());
            Cleanup();
        }
		public bool Equals(ComplaintAdded other)
		{
			if (ReferenceEquals(null, other)) return false;
			if (ReferenceEquals(this, other)) return true;
			return AddedBy.Equals(other.AddedBy) && other.AddedAt.Equals(AddedAt) && Equals(other.Subject, Subject) && Equals(other.Body, Body) && Equals(other.Area, Area);
		}