Ejemplo n.º 1
0
        public static bool CheckDuration(string HusbandNationalNum, string WifeNationalNum, int Days, IncidentType _IncidentType)
        {
            bool res = true;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                switch (_IncidentType)
                {
                case IncidentType.Divorce:
                    tblDivorceIncident divorceIncident = GetLastDivorceIncident(HusbandNationalNum, WifeNationalNum);
                    if (divorceIncident != null)
                    {
                        res = (DateTime.Now - DateTime.Parse(divorceIncident.IncidentDate)).TotalDays >= Days;
                    }
                    break;

                case IncidentType.Death:
                    tblMarriageContract marriageContract = db.tblMarriageContracts.Where(x => x.HusbandNationalNum == HusbandNationalNum).Where(y => y.WifeNationalNum == WifeNationalNum).OrderByDescending(z => z.IncidentNumber).FirstOrDefault();
                    if (marriageContract != null)
                    {
                        if (IsDead(marriageContract.HusbandNationalNum))
                        {
                            tblDeadRegistration deadRegistration = db.tblDeadRegistrations.Where(x => x.NationalNumber == HusbandNationalNum).FirstOrDefault();
                            if (deadRegistration != null)
                            {
                                res = (DateTime.Now - DateTime.Parse(deadRegistration.DeadDate)).TotalDays >= Days;
                            }
                        }
                    }
                    break;
                }
            }

            return(res);
        }
Ejemplo n.º 2
0
        public static bool IsDivorced(string HusbandNationalNum, string WifeNationalNum)
        {
            tblMarriageContract marriageContract = GetLastMarriageContract(HusbandNationalNum, WifeNationalNum);

            if (marriageContract == null)
            {
                return(false);
            }


            return(IsMarriageBeforeDivorce(HusbandNationalNum, WifeNationalNum, marriageContract.IncidentDate));
        }
Ejemplo n.º 3
0
        public static bool IsMarriage(string NationalNumber)
        {
            bool res = false;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblMarriageContract marriageContract = GetLastMarriageContract(NationalNumber);
                res = (marriageContract == null) ? false : true;
            }

            return(res);
        }
Ejemplo n.º 4
0
        public static bool IsDivorceBeforeMarriage(string HusbandNationalNum, string WifeNationalNum, string IncidentDate)
        {
            bool res = false;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblMarriageContract marriageContracts = db.tblMarriageContracts.Where(x => x.HusbandNationalNum == HusbandNationalNum).Where(y => y.WifeNationalNum == WifeNationalNum).OrderByDescending(z => z.IncidentDate).FirstOrDefault(); // آخر واقعة زواج

                res = GetDate(IncidentDate) < GetDate(marriageContracts.IncidentDate);
            }

            return(res);
        }
Ejemplo n.º 5
0
        private void FillDocument(tblMarriageContract marriageContract)
        {
            lbl_Amana.Text             = labelIssuedBy.Text = labelIssuedBy1.Text = Helper.GetAmanaNameByEmp(Session["CurrUser"]);
            lbl_Government.Text        = labelGovernorate.Text = Helper.GetAffairsNameByEmp(Session["CurrUser"]);
            labelFamilyNumber.Text     = marriageContract.FamilyNumber.ToString();
            labelIdHusband.Text        = marriageContract.HusbandNationalNum;
            labelIdWife.Text           = marriageContract.WifeNationalNum;
            labelNameController.Text   = Helper.GetControllerNameByEmp(Session["CurrUser"]);
            labelRegistrar.Text        = Helper.GetCivilRegistrarByEmp(Session["CurrUser"]);
            labelFirstNameHusbasd.Text = marriageContract.tblCitizen2.FirstName;
            var father = Helper.GetCitizen(marriageContract.tblCitizen2.FatherNationalNumber);

            labelFatherNameHusband.Text = (father != null) ? father.FirstName : string.Empty;
            var mother = Helper.GetCitizen(marriageContract.tblCitizen2.MotherNationalNumber);

            labelMotherNameHusband.Text         = (mother != null) ? mother.FirstName + " " + mother.LastName : string.Empty;
            labelPlaceBirthHusband.Text         = marriageContract.tblCitizen2.BirthPlace;
            labelReligionHusband.Text           = marriageContract.tblCitizen2.Religion;
            DateContract.Text                   = marriageContract.ContractDate;
            labelLastNameHusband.Text           = marriageContract.tblCitizen2.LastName;
            labelIdFatherHusband.Text           = (father != null) ? father.NationalNumber : string.Empty;
            labelIdMotherHusband.Text           = (mother != null) ? mother.NationalNumber : string.Empty;
            BirthdayHusband.Text                = marriageContract.tblCitizen2.Birthday;
            labelAlamanaHusband.Text            = Helper.GetAmanaNameByEmp(Session["CurrUser"]);
            labelPlaceEntryHusband.Text         = marriageContract.tblCitizen2.KiedPlace;
            labelRegistrationNumberHusbans.Text = marriageContract.tblCitizen2.KiedNumber;
            lblHusbandId.Text                   = marriageContract.tblCitizen2.Id.ToString();
            labelNotes.Text = marriageContract.Notes;

            labelRegistrationNumberWife.Text = marriageContract.tblCitizen3.KiedNumber;
            labelFirstNameWife.Text          = marriageContract.tblCitizen3.FirstName;
            father = Helper.GetCitizen(marriageContract.tblCitizen3.FatherNationalNumber);
            labelFatherNameWife.Text = (father != null) ? father.FirstName : string.Empty;
            mother = Helper.GetCitizen(marriageContract.tblCitizen3.MotherNationalNumber);
            labelMotherNameWife.Text            = (mother != null) ? mother.FirstName + " " + mother.LastName : string.Empty;
            labelPalceBirthWife.Text            = marriageContract.tblCitizen3.BirthPlace;
            labelReligionWife.Text              = marriageContract.tblCitizen3.Religion;
            DateContract.Text                   = marriageContract.ContractDate;
            labelLastNameWife.Text              = marriageContract.tblCitizen3.LastName;
            labelIdFatherWife.Text              = (father != null) ? father.NationalNumber : string.Empty;
            labelIdMotherWife.Text              = (mother != null) ? mother.NationalNumber : string.Empty;
            BirthWife.Text                      = marriageContract.tblCitizen3.Birthday;
            labelAlmanWife.Text                 = Helper.GetAmanaNameByEmp(Session["CurrUser"]);
            labelPlaceEntryWife.Text            = marriageContract.tblCitizen3.KiedPlace;
            labelRegistrationNumberHusbans.Text = marriageContract.tblCitizen2.KiedNumber;
            lblWifeId.Text                      = marriageContract.tblCitizen3.Id.ToString();

            lblReference.Text         = marriageContract.Reference;
            DateDocument.Text         = lblMarrageDate.Text = marriageContract.ContractDate;
            label_DocumentNumber.Text = labelDocumentNumber.Text = marriageContract.IncidentNumber.ToString();
        }
Ejemplo n.º 6
0
        public static bool IsWidow(string WifeNationalNum)
        {
            bool res = false;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblMarriageContract marriageContract = db.tblMarriageContracts.Where(x => x.WifeNationalNum == WifeNationalNum).OrderByDescending(y => y.IncidentNumber).FirstOrDefault();

                if (marriageContract != null)
                {
                    res = IsDead(marriageContract.HusbandNationalNum);
                }
            }

            return(res);
        }
Ejemplo n.º 7
0
        private static tblMarriageContract GetLastMarriageContract(string HusbandNationalNum, string WifeNationalNum)
        {
            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblMarriageContract marriageContract = db.tblMarriageContracts.Where(x => x.HusbandNationalNum == HusbandNationalNum).Where(y => y.WifeNationalNum == WifeNationalNum).OrderByDescending(z => z.IncidentNumber).FirstOrDefault();

                if (marriageContract == null)
                {
                    return(null);
                }

                //if (!IsDivorced(marriageContract.HusbandNationalNum, marriageContract.WifeNationalNum))
                return(marriageContract);
                //else
                //return null;
            }
        }
Ejemplo n.º 8
0
        public static bool CheckIsWife(string HusbandNationalNum, string WifeNationalNum)
        {
            bool res = false;

            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblMarriageContract marriageContracts = db.tblMarriageContracts.Where(x => x.HusbandNationalNum == HusbandNationalNum).Where(y => y.WifeNationalNum == WifeNationalNum).OrderByDescending(z => z.IncidentDate).FirstOrDefault();
                tblDivorceIncident  divorceIncidents  = db.tblDivorceIncidents.Where(x => x.HusbandNationalNum == HusbandNationalNum).Where(y => y.WifeNationalNum == WifeNationalNum).OrderByDescending(z => z.IncidentDate).FirstOrDefault();

                if (divorceIncidents == null && marriageContracts != null)
                {
                    res = true;
                }

                if (marriageContracts != null && divorceIncidents != null)
                {
                    res = GetDate(marriageContracts.IncidentDate) > GetDate(divorceIncidents.IncidentDate);
                }
            }

            return(res);
        }
Ejemplo n.º 9
0
        // لمعرفة فيما إذا كان المواطن متزوج أم لا
        private static tblMarriageContract GetLastMarriageContract(string NationalNum)
        {
            using (EGovernmentEntities db = new EGovernmentEntities())
            {
                tblMarriageContract husbandMarriageContract = db.tblMarriageContracts.Where(x => x.HusbandNationalNum == NationalNum).OrderByDescending(z => z.IncidentNumber).FirstOrDefault();

                if (husbandMarriageContract != null)
                {
                    if (!IsDivorced(husbandMarriageContract.HusbandNationalNum, husbandMarriageContract.WifeNationalNum))
                    {
                        return(husbandMarriageContract);
                    }
                    else
                    {
                        return(null);
                    }
                }


                tblMarriageContract wifeMarriageContract = db.tblMarriageContracts.Where(x => x.WifeNationalNum == NationalNum).OrderByDescending(z => z.IncidentNumber).FirstOrDefault();

                if (wifeMarriageContract != null)
                {
                    if (!IsDivorced(wifeMarriageContract.HusbandNationalNum, wifeMarriageContract.WifeNationalNum))
                    {
                        return(wifeMarriageContract);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 10
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int Penalty = Helper.GetPenalty(HusbandNationalNum.Text, (int)(DateTime.Today - DateTime.Parse(IncidentDate.Value)).TotalDays, IncidentType.Marriage);
                if (!Helper.CheckBalance(HusbandNationalNum.Text, Penalty))
                {
                    lblErrorMSG.Visible = true;
                    lblErrorMSG1.Text   = "لا يمكن تسجيل عقد الزواج لأن حسابك لا يحوي على المبلغ الكافي لتسديد الضريبة";
                    return;
                }
                else
                {
                    lblErrorMSG.Visible = false;
                }

                using (EGovernmentEntities db = new EGovernmentEntities())
                {
                    if (db.tblCitizens.Where(x => x.NationalNumber == txtFirstWitness.Text).ToList().Count == 0)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "الرقم الوطني المدخل للشاهد الأول غير موجود في قاعدة البيانات";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (db.tblCitizens.Where(x => x.NationalNumber == txtSecondWitness.Text).ToList().Count == 0)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "الرقم الوطني المدخل للشاهد الثاني غير موجود في قاعدة البيانات";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (HusbandNationalNum.Text == txtFirstWitness.Text || HusbandNationalNum.Text == txtSecondWitness.Text)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "لا يمكن للزوج بأن يكون أحد الشهود";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (WifeNationalNum.Text == txtFirstWitness.Text || WifeNationalNum.Text == txtSecondWitness.Text)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "لا يمكن للزوجة بأن تكون أحد الشهود";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (Helper.IsDead(txtFirstWitness.Text))
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "الشاهد الأول هو شخص متوفى";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (Helper.IsDead(txtSecondWitness.Text))
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "الشاهد الثاني هو شخص متوفى";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (txtFirstWitness.Text == txtSecondWitness.Text)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "لا يمكن الشهادة بشخص واحد";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (Helper.IsMarriageBeforeDivorce(HusbandNationalNum.Text, WifeNationalNum.Text, IncidentDate.Value))
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "لا يمكن إتمام العملية، لأن تاريخ الزواج يسبق تاريخ آخر واقعة طلاق";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (Helper.GetDate(IncidentDate.Value) > DateTime.Now)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "تاريخ حدوث الواقعة أكبر من التاريخ الحالي";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    if (Helper.GetDate(MarriageLicenseDate.Value) > DateTime.Now)
                    {
                        lblErrorMSG.Visible = true;
                        lblErrorMSG1.Text   = "تاريخ رخصة الزواج أكبر من التاريخ الحالي";
                        return;
                    }
                    else
                    {
                        lblErrorMSG.Visible = false;
                    }

                    tblMarriageContract marriageContract = new tblMarriageContract();

                    marriageContract.HusbandNationalNum = HusbandNationalNum.Text;
                    marriageContract.WifeNationalNum    = WifeNationalNum.Text;
                    marriageContract.FamilyNumber       = GenerateFamilyNumber(db);
                    marriageContract.ContractDate       = DateTime.Now.ToShortDateString();
                    marriageContract.Reference          = txtAuthorityAuthorizedContract.Text;
                    marriageContract.DocumentNumber     = int.Parse(txtDocumentNumber.Text);
                    marriageContract.DocumentDate       = DateTime.Now.ToShortDateString();
                    marriageContract.Notes                       = txtNotes.Text;
                    marriageContract.IncidentDate                = IncidentDate.Value;
                    marriageContract.MarriageLicenseNumber       = MarriageLicenseNumber.Text;
                    marriageContract.MarriageLicenseDate         = MarriageLicenseDate.Value;
                    marriageContract.PreMoney                    = PreMoney.Text;
                    marriageContract.PostMoney                   = PostMoney.Text;
                    marriageContract.MoneyStatus                 = ss1.Checked ? "1" : "2";
                    marriageContract.FirstWitnessNationalNumber  = txtFirstWitness.Text;
                    marriageContract.SecondWitnessNationalNumber = txtSecondWitness.Text;

                    db.tblMarriageContracts.AddObject(marriageContract);


                    Helper.EditSocialNumber(HusbandNationalNum.Text, SocialStatus.Marriad);
                    Helper.EditSocialNumber(WifeNationalNum.Text, SocialStatus.Marriad);

                    db.SaveChanges();

                    Helper.Pay(HusbandNationalNum.Text, Penalty);

                    Response.Redirect("/Finish");
                }
            }
        }