コード例 #1
0
        public JsonResult getyear(int compid, int compliancetypeid)
        {
            int             sd    = 0;
            int             ed    = 0;
            List <string>   years = new List <string>();
            ReportViewModel model = new ReportViewModel();

            OrgService.OrganizationServiceClient organizationservice = new OrgService.OrganizationServiceClient();
            string  strxmlcompliancetype = organizationservice.GetParticularCompliance(compliancetypeid);
            DataSet dsComplianceType     = new DataSet();

            dsComplianceType.ReadXml(new StringReader(strxmlcompliancetype));
            if (dsComplianceType.Tables.Count > 0)
            {
                string   ComplianceName = Convert.ToString(dsComplianceType.Tables[0].Rows[0]["Compliance_Type_Name"]);
                DateTime StartDate      = Convert.ToDateTime(dsComplianceType.Tables[0].Rows[0]["Start_Date"]);
                DateTime EndDate        = Convert.ToDateTime(dsComplianceType.Tables[0].Rows[0]["End_date"]);

                sd = StartDate.Year;
                ed = EndDate.Year;
            }

            string  strxmlyear = organizationservice.getDefaultCompanyDetails(compid);
            DataSet dsyear     = new DataSet();

            dsyear.ReadXml(new StringReader(strxmlyear));
            if (dsyear.Tables.Count > 0)
            {
                model.StartDate = Convert.ToDateTime(dsyear.Tables[0].Rows[0]["Calender_StartDate"]);
                model.yearid    = model.StartDate.Year;
                if (sd == ed)
                {
                    model.years = Enumerable.Range(model.yearid, DateTime.Now.Year - (model.yearid - 1)).OrderByDescending(i => i);
                    //model.yearid = DateTime.Now.Year;
                }
                else
                {
                    int count = DateTime.Now.Year - (model.yearid - 1);
                    for (int i = 1; i <= count; i++)
                    {
                        years.Add(model.yearid.ToString() + "-" + (model.yearid + 1));
                        ++model.yearid;
                    }
                    years.Reverse();

                    return(Json(years, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(model.years, JsonRequestBehavior.AllowGet));
        }