Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // add new project event to family
            //oPerson = new tblPersonsDB(vars.mstrCnn);

            moslemFamilyProject newFamilyProj  = new moslemFamilyProject();

            newFamilyProj.amount = Convert.ToInt32(txtAmount.Text);
            newFamilyProj.familyID =familyid;
            newFamilyProj.checknumber =txtchecknum.Text;
            newFamilyProj.date =dateTimePicker1.Value.Date;
            newFamilyProj.reason = txtReason.Text;

            db.AddTomoslemFamilyProjects(newFamilyProj);
            db.SaveChanges();
            btnAddFamily.Enabled = false;
            var query = from p in db.moslemFamilyProjects.Where(x => x.familyID == familyid)
                        select p;

            dtGridFamilyProjectHistory.DataSource = query.ToList<moslemFamilyProject>();
        }
Example #2
0
        private void RenderReport(moslemFamilyProject moslemFamilyProject)
        {
            List<PersonsInProjects> allFamiliesinProj=new List<PersonsInProjects>();
            ZakahEntities db = new ZakahEntities();
            var query  = from p in db.moslemFamilyProjects.Where(x => (x.date >= dateFrom.Value) && (x.date <= dateTo.Value))
                         select p;
               List<moslemFamilyProject> allprj = query.ToList<moslemFamilyProject>();
               foreach (moslemFamilyProject item in allprj)
               {
                   PersonsInProjects _personinproject = new PersonsInProjects(item.familyID);
                   _personinproject.date = Convert.ToDateTime(item.date).ToString("M/d/yyyy");

                   _personinproject.Amount = item.amount;
                   _personinproject.Titleamount = "المبلغ";
                  // _personinproject.ProjectName = comboBox1.Text;
                   allFamiliesinProj.Add(_personinproject);
               }

               this.reportViewer1.LocalReport.DataSources.Clear();
               this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet_PersoninFamily", allFamiliesinProj));
               ReportParameter p1 = new ReportParameter("DateFrom", dateFrom.Value.ToString("mm/dd/yyyy"));
               ReportParameter p2 = new ReportParameter("DateTo", dateTo.Value.ToString("mm/dd/yyyy"));
               ReportParameter p3 = new ReportParameter("project", comboBox1.Text);

               reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3 });
               reportViewer1.Visible = true;
               this.reportViewer1.RefreshReport();
        }
Example #3
0
        private void RenderReport(moslemFamilyProject moslemFamilyProject)
        {
            List<FamilyPerson> allFamiliesinProj=new List<FamilyPerson>();
            List<Person> allprj=new List<Person>();
            ZakahEntities db = new ZakahEntities();

            var query = from f in db.FamilyPersons.Where(x => x.street.StartsWith(textStreet.Text))
                        join p in db.Persons.Where(x => (x.LastName.StartsWith(textBox1.Text))) on f.id equals p.FamilyID
                        select new { f.street, p.FamilyID, p.IDnum, f.Husbandid, f.wifeid, f.cellnumber, f.Telephone, p.LastName, f.HomeNumber };
            if (!string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textStreet.Text))
            {
            // search by both;
                query = from f in db.FamilyPersons
                        join p in db.Persons.Where(x => (x.LastName.StartsWith(textBox1.Text))) on f.id equals p.FamilyID
                        select new { f.street, p.FamilyID, p.IDnum, f.Husbandid, f.wifeid, f.cellnumber, f.Telephone, p.LastName, f.HomeNumber };

            }
            if (string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrEmpty(textStreet.Text))
            {
                // search by both;
                query = from f in db.FamilyPersons.Where(x => x.street.StartsWith(textStreet.Text))
                        join p in db.Persons on f.id equals p.FamilyID
                        select new { f.street, p.FamilyID, p.IDnum, f.Husbandid, f.wifeid, f.cellnumber, f.Telephone, p.LastName, f.HomeNumber };

            }

            if (!string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrEmpty(textStreet.Text))
            {
                // search by both;
                query = from f in db.FamilyPersons.Where(x => x.street.StartsWith(textStreet.Text))
                        join p in db.Persons.Where(x => (x.LastName.StartsWith(textBox1.Text))) on f.id equals p.FamilyID
                        select new { f.street, p.FamilyID, p.IDnum, f.Husbandid, f.wifeid, f.cellnumber, f.Telephone, p.LastName, f.HomeNumber };
               ;

            }

            var query2 = from a in query
                         group a by a.FamilyID into newfamily
                         select new
                         {
                             PostalCode = newfamily.Key,
                             newfamily = newfamily
                         };

             foreach (var item1 in query2)
                {
                    foreach (var item in item1.newfamily)
                    {
                        FamilyPerson currentFamilyPerson = db.FamilyPersons.FirstOrDefault(x => (x.Husbandid == item.IDnum) || (x.wifeid == item.IDnum));
                        FamilyPhoneBook _familyDetails = new FamilyPhoneBook(currentFamilyPerson.id);
                        // _familyDetails.date = Convert.ToDateTime(item.date).ToString("M/d/yyyy");
                        //   _familyDetails.Amount = item.amount;
                        _familyDetails.Titleamount = "مبلغ الترميم";
                        //_familyDetails.AdditionalData += "عدد الغرف :" + item.RoomNumbers + "\n";
                        //_familyDetails.AdditionalData += " احتياجات الترميم :" + item.Tarmimdemands + "\n";
                        //_familyDetails.AdditionalData += "  تكاليف الترميم :" + item.TarmimTakalef + "\n";
                        //_familyDetails.AdditionalData += "   ملاحظات :" + item.Note + "\n";
                        // _personinproject.ProjectName = comboBox1.Text;
                        allFamiliesinProj.Add(_familyDetails);
                        break;
                    }

                }

            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet_PersoninFamily", allFamiliesinProj));
            //ReportParameter p1 = new ReportParameter("DateFrom", dateFrom.Value.ToString("mm/dd/yyyy"));
            //ReportParameter p2 = new ReportParameter("DateTo", dateTo.Value.ToString("mm/dd/yyyy"));
            //ReportParameter p3 = new ReportParameter("project", comboBox1.Text);
            //ReportParameter p4 = new ReportParameter("MasrofSummary", MasrofSummary);

            //reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4 });
            reportViewer1.Visible = true;
            this.reportViewer1.RefreshReport();
        }