示例#1
0
    private void showHeaderDetailByResidentID()
    {
        List <ADLHeaderDetail> aDLHeaderDetailByResident = ADLHeaderDetailManager.GetAllADLHeaderDetailsByResidentID(int.Parse(Request.QueryString["ResidentID"]));

        if (aDLHeaderDetailByResident.Count == 0)
        {
            aDLHeaderDetailByResident = ADLHeaderDetailManager.GetDefaultAfterInsertADLHeaderDetails(int.Parse(Request.QueryString["ResidentID"]));
        }
        List <ADLHeader> aDLHeaderbyResident = new List <ADLHeader>();

        foreach (ADLHeaderDetail item in aDLHeaderDetailByResident)
        {
            bool needToAdd = true;
            if (aDLHeaderbyResident.Count != 0)
            {
                foreach (ADLHeader itm in aDLHeaderbyResident)
                {
                    if (itm.ADLHeaderID == item.ADLHeaderID)
                    {
                        needToAdd = false;
                        break;
                    }
                }
            }

            if (needToAdd)
            {
                ADLHeader newADLHeader = new ADLHeader();
                newADLHeader.ADLHeaderID   = item.ADLHeaderID;
                newADLHeader.ADLHeaderName = item.ExtraField1;

                aDLHeaderbyResident.Add(newADLHeader);
            }
        }

        gvHeader.DataSource = aDLHeaderbyResident;
        gvHeader.DataBind();

        foreach (GridViewRow gvr in gvHeader.Rows)
        {
            HiddenField hfADLHeaderID = (HiddenField)gvr.FindControl("hfADLHeaderID");
            GridView    gvDetail      = (GridView)gvr.FindControl("gvDetail");

            List <ADLDetail> aDLDetailbyResident = new List <ADLDetail>();

            foreach (ADLHeaderDetail item in aDLHeaderDetailByResident)
            {
                if (item.ADLHeaderID.ToString() == hfADLHeaderID.Value)
                {
                    bool needToAdd = true;
                    if (aDLDetailbyResident.Count != 0)
                    {
                        foreach (ADLDetail itm in aDLDetailbyResident)
                        {
                            if (itm.ADLDetailID == item.ADLDetailID)
                            {
                                needToAdd = false;
                                break;
                            }
                        }
                    }

                    if (needToAdd)
                    {
                        ADLDetail newADLDetail = new ADLDetail();
                        newADLDetail.ADLDetailID   = item.ADLDetailID;
                        newADLDetail.ADLDetailName = item.ExtraField2;
                        newADLDetail.ExtraField1   = item.ADLHeaderDetailID.ToString();
                        aDLDetailbyResident.Add(newADLDetail);
                    }
                }
            }

            gvDetail.DataSource = aDLDetailbyResident;
            gvDetail.DataBind();

            foreach (GridViewRow gvrDetail in gvDetail.Rows)
            {
                DropDownList    ddlADLStatusInGrid   = (DropDownList)gvrDetail.FindControl("ddlADLStatusInGrid");
                HiddenField     hfADLDetailID        = (HiddenField)gvrDetail.FindControl("hfADLDetailID");
                RadioButtonList rbtnlADLStatusInGrid = (RadioButtonList)gvrDetail.FindControl("rbtnlADLStatusInGrid");

                ddlADLStatusInGrid.Items.Clear();
                ListItem li = new ListItem("Select >>", "-1");
                ddlADLStatusInGrid.Items.Add(li);

                foreach (ListItem item in ddlADLStatus.Items)
                {
                    if (item.Value == hfADLDetailID.Value)
                    {
                        ddlADLStatusInGrid.Items.Add(new ListItem(item.Text, item.Text));
                        rbtnlADLStatusInGrid.Items.Add(new ListItem(item.Text, item.Text));
                    }
                }

                //li = new ListItem("Other", "0");
                //ddlADLStatusInGrid.Items.Add(li);
                //rbtnlADLStatusInGrid.Items.Add(li);
                //rbtnlADLStatusInGrid.SelectedIndex = 0;
            }
        }
    }
    private void loadList()
    {
        DateTime startDate = DateTime.Parse(ddlYears.SelectedValue + "-" + ddlMonths.SelectedValue + "-1");
        DateTime endDate   = startDate.AddMonths(1).AddDays(-1);

        string html = "";

        //Initial
        html += "<table  border='0' class='reportTable'><tr>";
        html += "<tr><td colspan='2'></td>";

        int totalDayOfthisMonth = 0;

        for (int i = 0; startDate.AddDays(i) <= endDate; i++)
        {
            html += "<td style='text-align:center'>" + startDate.AddDays(i).ToString("dd") + "<br/>" + startDate.AddDays(i).DayOfWeek.ToString().Substring(0, 1) + "</td>";
            totalDayOfthisMonth = i;
        }
        html += "</tr>";
        List <ADLHeaderDetail> aDLHeaderDetailByResident = ADLHeaderDetailManager.GetAllADLHeaderDetailsByResidentID(int.Parse(Request.QueryString["ResidentID"]));

        if (aDLHeaderDetailByResident.Count == 0)
        {
            aDLHeaderDetailByResident = ADLHeaderDetailManager.GetDefaultAfterInsertADLHeaderDetails(int.Parse(Request.QueryString["ResidentID"]));
        }
        //DataSet ds = MedicationTimeManager.GetAllMedicationTimesByResident(int.Parse(Request.QueryString["ResidentID"]));
        //DataSet dsAllData = MedicineTimenDateManager.GetMedicationTimenDateByResidentID(int.Parse(Request.QueryString["ResidentID"]));
        DataSet dsAllData = ADLHeaderDetailnDateTimeManager.GetAllADLHeaderDetailnDateTimeByResidentIDWithDateRange(int.Parse(Request.QueryString["ResidentID"]), startDate, endDate);

        foreach (ADLHeaderDetail headerDetail in aDLHeaderDetailByResident)
        {
            html += "<tr><td>" + headerDetail.ExtraField1 + "</td><td>" + headerDetail.ExtraField2 + "</td>";
            //html += "</tr>" + "<tr><td>" + dr["MedicineName"] + "</td><td colspan='" + (totalDayOfthisMonth + 1).ToString() + "'>Report will goes here</td>";

            for (int i = 0; startDate.AddDays(i) <= endDate; i++)
            {
                bool isFount = false;
                foreach (DataRow drAllData in dsAllData.Tables[0].Rows)
                {
                    if (headerDetail.ADLHeaderDetailID.ToString() == drAllData["ADLHeaderDetailID"].ToString() && startDate.AddDays(i).ToString("yyyy-MM-dd") == DateTime.Parse(drAllData["ADLDateTime"].ToString()).ToString("yyyy-MM-dd"))
                    {
                        isFount = true;
                        if (drAllData["ExtraField1"].ToString() == "")
                        {
                            html += "<td></td>";
                            break;
                        }
                        else
                        {
                            html += "<td style='background-color:#DDDDDD;color:Black;'>" + drAllData["ExtraField1"].ToString() + "<br/>[" + drAllData["ExtraField2"].ToString() + "]</td>";
                            break;
                        }
                    }
                }

                if (!isFount)
                {
                    html += "<td></td>";
                }
            }

            html += "</tr>";
        }

        html += "</table>";

        lblMonthlyPrint.Text = html;
    }