Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // validate inputs
            // add inputs to database

               // FamilyPerson _family = new FamilyPerson();
            ZakahEntities db = new ZakahEntities();
            Person _currentPerson = new Person();
            FamilyPerson newFamilyRelation = new FamilyPerson();

            newFamilyRelation.Husbandid = txtHusbandid.Text;
            newFamilyRelation.wifeid = txtwifeid.Text;
            newFamilyRelation.street = txtStreet.Text;
            newFamilyRelation.CityID = Convert.ToInt32(drpCity.SelectedValue);
            newFamilyRelation.HomeNumber = txtHomeNum.Text;
            newFamilyRelation.POBOX = txtPOBOX.Text;
            newFamilyRelation.mikod = Convert.ToInt32(txtMikod.Text);
            newFamilyRelation.Telephone = txtTelephone.Text;
            newFamilyRelation.cellnumber = txtCell.Text;
            newFamilyRelation.childnumunder18 = Convert.ToInt32(txtChildesUnder18.Text);
            newFamilyRelation.childNumabove18 = Convert.ToInt32(txtChiledabove18.Text);
            newFamilyRelation.workType = txtWork.Text;
            newFamilyRelation.Income = Convert.ToInt32(txtIncome.Text);
            if (string.Empty != txtOjra.Text)
            {
                newFamilyRelation.Mashkanta_Ojra = Convert.ToInt32(txtOjra.Text);
            }
            newFamilyRelation.ownHouse = chkOwnHouse.Checked;

            db.AddToFamilyPersons(newFamilyRelation);
            db.SaveChanges();

            /*db.SaveChanges();*/
            _currentPerson.FamilyID = newFamilyRelation.id;
            _currentPerson.IDnum = txtHusbandid.Text;
            _currentPerson.FirstName = txtHusFirstname.Text;
            _currentPerson.FatherName = txtHusFatherName.Text;
            _currentPerson.LastName = txtHusFamily.Text;
            db.AddToPersons(_currentPerson);

            _currentPerson = new Person();
            _currentPerson.FamilyID = newFamilyRelation.id;
            _currentPerson.IDnum = txtwifeid.Text;
            _currentPerson.FirstName = txtWifeFirstname.Text;
            _currentPerson.FatherName = txtWifeFatherName.Text;
            _currentPerson.LastName = txtWifeFamily.Text;
            db.AddToPersons(_currentPerson);
            db.AddToPersons(_currentPerson);
            db.SaveChanges();

            btnAddFamily.Enabled =false;
            MessageBox.Show("تم اضافة العائلة بنجاح");
            // we should add id number for husband and wife
            //  this.FillGridMySites(this.oMySites.GetDataList(tblMySitesDB.lists.All, tblMySitesDB.Where.None, tblMySitesDB.Order.ByID));
        }
Esempio n. 2
0
        void txtid_Leave(object sender, System.EventArgs e)
        {
            Person WifePerson = new Person();
            // check if there is id like that at table FamilyPerson
            //if have a relation in family person then
            bool isthereahusbandinsystem = false;
            if (txtid.Text.Length > 8)
            {
                //  personDetails = this.oPerson.GetPersonDetailsbyID(txtid.Text);

                currentPerson = db.Persons.FirstOrDefault(x => x.IDnum == txtid.Text);
                FamilyPerson family_rel = db.FamilyPersons.FirstOrDefault(x => x.Husbandid == currentPerson.IDnum || x.wifeid == currentPerson.IDnum);
                familyid = Convert.ToInt32(family_rel.id);
                var query = from p in db.HomeFixesProjects.Where(x => x.familyID == familyid)
                            select p;

                WifePerson = db.Persons.FirstOrDefault(x => (x.FamilyID == familyid) && (x.IDnum != txtid.Text));

                dtGridFamilyProjectHistory.DataSource = query.ToList<HomeFixesProject>();
            }

            if (null == currentPerson)
            {
                //  isthereahusbandinsystem
                MessageBox.Show("لم يتم العثور على الشخص");
                // clear id
                txtid.Text = string.Empty;
                txtid.Focus();

            }
            else
            {
                //  DataRow row = personDetails.Rows[0];
                btnAddFamily.Enabled = true;
                //  txtFullname.Text =row["FirstName"].ToString() +" "+ row["FatherName"].ToString() + " "+  row["LastName"].ToString();
                txtFullname.Text = currentPerson.FirstName + " " + currentPerson.FatherName + " " + currentPerson.LastName;

                familyid = Convert.ToInt32(currentPerson.FamilyID);
                txtFullNameWife.Text = WifePerson.FirstName + " " + WifePerson.FatherName + " " + WifePerson.LastName;
                txtIdWife.Text = WifePerson.IDnum;

                // fill dtGridFamilyProjectHistory history

                //oPerson.GetFamilyMoslemFamilyProjectbyID(familyid);

                int sum = 0;
                for (int i = 0; i < dtGridFamilyProjectHistory.Rows.Count; ++i)
                {
                    sum += Convert.ToInt32(dtGridFamilyProjectHistory.Rows[i].Cells["amount"].Value);
                }
                lblsumamount.Text = sum.ToString();

                txtAmount.Focus();
            }
        }
Esempio n. 3
0
        void txtid_Leave(object sender, System.EventArgs e)
        {
            // check if there is id like that at table FamilyPerson
            //if have a relation in family person then
            bool isthereahusbandinsystem = false;
            if (txtid.Text.Length > 8)
            {
                currentPerson = db.Persons.FirstOrDefault(x => x.IDnum == txtid.Text);

            }

            if (null == currentPerson)
            {
                //  isthereahusbandinsystem
                MessageBox.Show("لم يتم العثور على الشخص");
                // clear id
                txtid.Text = string.Empty;
                txtid.Focus();

            }
            else
            {

                //btnAddFamily.Enabled =true;
                txtFullname.Text = currentPerson.FirstName + " " + currentPerson.FatherName + " " + currentPerson.LastName;
                /*List<Iprojects.Data.moslemFamilyProject> ff= .ToList<moslemFamilyProject>();*/
                var query = from p in db.moslemFamilyProjects.Where(x => x.familyID == currentPerson.FamilyID)
                         select p;

                List<moslemFamilyProject>  ListFamilyMoslemproj = query.ToList<moslemFamilyProject>();

               var query2 = from p in db.FoodBoxProjects.Where(x => x.familyID == currentPerson.FamilyID) select p;

                List<FoodBoxProject> ListFoodBoxmproj = query2.ToList<FoodBoxProject>();

                var query3 = from p in db.HomeFixesProjects.Where(x => x.familyID == currentPerson.FamilyID) select p;

                List<HomeFixesProject> ListHomeFix = query3.ToList<HomeFixesProject>();

                var query4 = from p in db.SchoolBagsProjects.Where(x => x.familyID == currentPerson.FamilyID) select p;

                List<SchoolBagsProject> ListSchoolBags = query4.ToList<SchoolBagsProject>();

            List<Person> ListPerson = new List<Person>();
                ListPerson.Add(currentPerson);

                this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetMoslemFamily", ListFamilyMoslemproj));
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetFoodBox", ListFoodBoxmproj));
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetPerson", ListPerson));
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetHomeFix", ListHomeFix));
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetSchoolBags", ListSchoolBags));

                //this.reportViewer1.Reset();
                //this.reportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc");
               // ReportDataSource rds = new ReportDataSource("DataSet1",AllFamilies.GetAllProjects);
               // this.reportViewer1.LocalReport.DataSources = AllFamilies.GetAllProjects;

                //this.reportViewer1.DataBind();
               // reportmoslemFamilyProjectBindingSource.DataSource = AllFamilies.GetAllProjects;
                // Below code demonstrate the Parameter passing method. Use only if you have parameters into the reports.

            ReportParameter p1 = new ReportParameter("FullName", currentPerson.FirstName + " " + currentPerson.FatherName + " " + currentPerson.LastName);
            ReportParameter p2 = new ReportParameter("PersonID", currentPerson.IDnum);

            reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1 ,p2});
            reportViewer1.Visible = true;

                this.reportViewer1.RefreshReport();

            }
        }