/// <summary>
        /// Create a new tblCitizen object.
        /// </summary>
        /// <param name="firstName">Initial value of the FirstName property.</param>
        /// <param name="lastName">Initial value of the LastName property.</param>
        /// <param name="nationalNumber">Initial value of the NationalNumber property.</param>
        /// <param name="birthday">Initial value of the Birthday property.</param>
        /// <param name="birthPlace">Initial value of the BirthPlace property.</param>
        /// <param name="amana">Initial value of the Amana property.</param>
        /// <param name="kiedPlace">Initial value of the KiedPlace property.</param>
        /// <param name="kiedNumber">Initial value of the KiedNumber property.</param>
        /// <param name="gender">Initial value of the Gender property.</param>
        /// <param name="socialStatus">Initial value of the SocialStatus property.</param>
        /// <param name="religion">Initial value of the Religion property.</param>
        public static tblCitizen CreatetblCitizen(global::System.String firstName, global::System.String lastName, global::System.String nationalNumber, global::System.String birthday, global::System.String birthPlace, global::System.String amana, global::System.String kiedPlace, global::System.String kiedNumber, global::System.String gender, global::System.String socialStatus, global::System.String religion)
        {
            tblCitizen tblCitizen = new tblCitizen();

            tblCitizen.FirstName      = firstName;
            tblCitizen.LastName       = lastName;
            tblCitizen.NationalNumber = nationalNumber;
            tblCitizen.Birthday       = birthday;
            tblCitizen.BirthPlace     = birthPlace;
            tblCitizen.Amana          = amana;
            tblCitizen.KiedPlace      = kiedPlace;
            tblCitizen.KiedNumber     = kiedNumber;
            tblCitizen.Gender         = gender;
            tblCitizen.SocialStatus   = socialStatus;
            tblCitizen.Religion       = religion;
            return(tblCitizen);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the tblCitizen EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblCitizen(tblCitizen tblCitizen)
 {
     base.AddObject("tblCitizen", tblCitizen);
 }
Пример #3
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                if (chkClear.Checked)
                {
                    foreach (tblCitizen item in db.tblCitizen)
                    {
                        db.tblCitizen.DeleteObject(item);
                    }
                }

                Random        r = new Random();
                List <string> lstNationalNumbers = new List <string>();
                for (int i = 0; i < numRows.Value; i++)
                {
                    tblCitizen newCitizen = new tblCitizen();
                    newCitizen.Gender = (i % 2 == 0) ? "1" : "0";

                    if (newCitizen.Gender == "1")
                    {
                        newCitizen.FirstName = lstMaleNames[r.Next(0, lstMaleNames.Count)];
                    }
                    else
                    {
                        newCitizen.FirstName = lstFemaleNames[r.Next(0, lstFemaleNames.Count)];
                    }

                    newCitizen.LastName = lstMaleNames[r.Next(0, lstMaleNames.Count)];
                    //newCitizen.FatherName = lstMaleNames[r.Next(0, lstMaleNames.Count)];
                    //newCitizen.MotherName = lstFemaleNames[r.Next(0, lstFemaleNames.Count)];
                    newCitizen.NationalNumber = GetNationalNumber(db, lstNationalNumbers);
                    lstNationalNumbers.Add(newCitizen.NationalNumber);
                    newCitizen.Birthday     = GetRandomDateTime();
                    newCitizen.BirthPlace   = lstGovernorate[r.Next(0, lstGovernorate.Count)];
                    newCitizen.Amana        = "الأمانة المركزية";
                    newCitizen.KiedPlace    = newCitizen.BirthPlace;
                    newCitizen.KiedNumber   = r.Next(1, 60).ToString();
                    newCitizen.SocialStatus = r.Next(1, 5).ToString();
                    newCitizen.Religion     = lstReligion[r.Next(0, 3)];

                    db.tblCitizen.AddObject(newCitizen);
                }
                db.SaveChanges();


                foreach (var item in db.tblCitizen)
                {
                    tblCitizen newCitizen;
                    #region Father
                    newCitizen                = new tblCitizen();
                    newCitizen.Gender         = "1";
                    newCitizen.SocialStatus   = "2";
                    newCitizen.Religion       = lstReligion[r.Next(0, 3)];
                    newCitizen.KiedPlace      = item.KiedPlace;
                    newCitizen.KiedNumber     = item.KiedNumber;
                    newCitizen.Amana          = "الأمانة المركزية";
                    newCitizen.BirthPlace     = newCitizen.KiedPlace;
                    newCitizen.Birthday       = DateTime.Parse(item.Birthday).AddYears(-15).AddMonths(-5).AddDays(-3).ToShortDateString();
                    newCitizen.LastName       = item.LastName;
                    newCitizen.FirstName      = lstMaleNames[r.Next(0, lstMaleNames.Count)];
                    newCitizen.NationalNumber = GetNationalNumber(db, lstNationalNumbers);
                    item.FatherNationalNumber = newCitizen.NationalNumber;

                    lstNationalNumbers.Add(newCitizen.NationalNumber);

                    db.tblCitizen.AddObject(newCitizen);
                    #endregion

                    #region Mother
                    newCitizen                = new tblCitizen();
                    newCitizen.Gender         = "0";
                    newCitizen.SocialStatus   = "2";
                    newCitizen.Religion       = lstReligion[r.Next(0, 3)];
                    newCitizen.KiedPlace      = item.KiedPlace;
                    newCitizen.KiedNumber     = r.Next(1, 60).ToString();
                    newCitizen.Amana          = "الأمانة المركزية";
                    newCitizen.BirthPlace     = newCitizen.KiedPlace;
                    newCitizen.Birthday       = DateTime.Parse(item.Birthday).AddYears(-10).AddMonths(-3).AddDays(-1).ToShortDateString();
                    newCitizen.LastName       = lstMaleNames[r.Next(0, lstMaleNames.Count)];
                    newCitizen.FirstName      = lstFemaleNames[r.Next(0, lstFemaleNames.Count)];
                    newCitizen.NationalNumber = GetNationalNumber(db, lstNationalNumbers);
                    item.MotherNationalNumber = newCitizen.NationalNumber;

                    lstNationalNumbers.Add(newCitizen.NationalNumber);

                    db.tblCitizen.AddObject(newCitizen);
                    #endregion


                    db.tblCitizen.AddObject(newCitizen);
                }
                db.SaveChanges();
                MessageBox.Show("تم الحفظ بنجاح");
            }
        }