コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.parent.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string                 templatepath = ConfigurationManager.AppSettings["TemplatePath"].ToString();
            string                 action       = Request["action"];
            string                 id           = Request["id"];
            Document               srcDoc       = null;
            BookmarkCollection     marks        = null;
            IList <EasyDictionary> dics         = null;
            string                 filename     = "";

            if (!string.IsNullOrEmpty(id))
            {
                pEnt = Project.Find(id);
            }
            switch (action)
            {
            case "loadproject":
                string ProjectName = Request["ProjectName"];
                if (!string.IsNullOrEmpty(ProjectName))
                {
                    where = "and ProjectName like '%" + ProjectName + "%' ";
                }
                sql = @"select * from NCRL_SP..Project where BelongCmp = 'ZX' " + where;
                dt  = DataHelper.QueryDataTable(GetPageSql(sql));
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + ",total:" + totalProperty + "}");
                Response.End();
                break;

            case "delete":
                Delete();
                break;

            case "Recycle":
                Recycle();
                break;

            case "loadexportfile":
                sql = "select Id,Name,CreateTime from FileItem where ProjectId='" + id + "' and Path='导出' order by CreateTime asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{innerrows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "export_opinioncover":    //意见封面
                try
                {
                    srcDoc = new Document(templatepath + "审查意见封面.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        Bookmark mark = marks[j];
                        if (ContainProperty(pEnt, mark.Name))
                        {
                            mark.Text = pEnt.GetValue(mark.Name) + "";
                        }
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_审查意见封面.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "exporthegeshu":
                srcDoc = new Document(templatepath + "审查合格书_市政工程_房屋建筑.doc");
                marks  = srcDoc.Range.Bookmarks;
                for (int j = 0; j < marks.Count; j++)
                {
                    Bookmark mark = marks[j];
                    if (ContainProperty(pEnt, mark.Name))
                    {
                        mark.Text = pEnt.GetValue(mark.Name) + "";
                    }
                }
                sql  = @"select a.MajorName,(select top 1 SortIndex from SysEnumeration where ParentId='b640c40c-e2a9-41a8-bd28-d8ff9d71ff94' and Name=a.MajorName) as SortIndex
                                 from NCRL_SP..ProjectUser a where a.ProjectId='" + pEnt.Id + "' order by SortIndex asc";
                dics = DataHelper.QueryDictList(sql);
                int i = 1;
                foreach (EasyDictionary dic in dics)
                {
                    if (dic.Get <string>("MajorName") != "勘察")
                    {
                        if (marks["Major" + i] != null)
                        {
                            marks["Major" + i].Text = dic.Get <string>("MajorName");
                        }
                        i++;
                    }
                }
                filename = pEnt.ProjectName.Replace("#", "") + "_审查合格书.doc";
                srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                UpdateFileItem(filename);
                break;

            case "export_beiandengjibiao":
                try
                {
                    srcDoc = new Document(templatepath + "附件10施工图设计文件审查备案登记表.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        Bookmark mark = marks[j];
                        if (ContainProperty(pEnt, mark.Name))
                        {
                            mark.Text = pEnt.GetValue(mark.Name) + "";
                        }
                    }
                    if (marks["Layer"] != null)
                    {
                        marks["Layer"].Text = "地上层数:" + pEnt.UpperLayers + (string.IsNullOrEmpty(pEnt.DownLayers) ? "" : "地下层数:" + pEnt.DownLayers);
                    }
                    if (marks["KanChaIfBeiAn"] != null)
                    {
                        marks["KanChaIfBeiAn"].Text = string.IsNullOrEmpty(pEnt.KanChaUnitBeiAnNo) ? "否" : "是";
                    }
                    if (marks["SheJiIfBeiAn"] != null)
                    {
                        marks["SheJiIfBeiAn"].Text = string.IsNullOrEmpty(pEnt.SheJiUnitBeiAnNo) ? "否" : "是";
                    }
                    sql  = @"select a.*,(select top 1 SortIndex from NCRL_Portal..SysEnumeration where Name=a.MajorName and ParentId='b640c40c-e2a9-41a8-bd28-d8ff9d71ff94') as SortIndex
                        from NCRL_SP..KanChaSheJi a where a.ProjectId='" + pEnt.Id + "' order by SortIndex asc";
                    dics = DataHelper.QueryDictList(sql);    //勘察设计人员
                    int index = 1;
                    foreach (EasyDictionary dic in dics)
                    {
                        if (dic.Get <string>("Position") == "注册土木工程师(岩土)")
                        {
                            if (marks["ZhuCeYanTuName"] != null)
                            {
                                marks["ZhuCeYanTuName"].Text = dic.Get <string>("UserName");
                            }
                            if (marks["ZhuCeYanTuSealNo"] != null)
                            {
                                marks["ZhuCeYanTuSealNo"].Text = dic.Get <string>("SealNo");
                            }
                            if (marks["ZhuCeYanTuShenFenZheng"] != null)
                            {
                                marks["ZhuCeYanTuShenFenZheng"].Text = dic.Get <string>("ShenFenZhengNo");
                            }
                        }
                        else if (dic.Get <string>("Position") == "一级注册建筑师")
                        {
                            if (marks["ZhuCeJianZaoShiName"] != null)
                            {
                                marks["ZhuCeJianZaoShiName"].Text = dic.Get <string>("UserName");
                            }
                            if (marks["ZhuCeJianZaoShiSealNo"] != null)
                            {
                                marks["ZhuCeJianZaoShiSealNo"].Text = dic.Get <string>("SealNo");
                            }
                            if (marks["ZhuCeJianZaoShiShenFenZheng"] != null)
                            {
                                marks["ZhuCeJianZaoShiShenFenZheng"].Text = dic.Get <string>("ShenFenZhengNo");
                            }
                        }
                        else if (dic.Get <string>("Position") == "一级注册结构师")
                        {
                            if (marks["ZhuCeJieGouShiName"] != null)
                            {
                                marks["ZhuCeJieGouShiName"].Text = dic.Get <string>("UserName");
                            }
                            if (marks["ZhuCeJieGouShiSealNo"] != null)
                            {
                                marks["ZhuCeJieGouShiSealNo"].Text = dic.Get <string>("SealNo");
                            }
                            if (marks["ZhuCeJieGouShiShenFenZheng"] != null)
                            {
                                marks["ZhuCeJieGouShiShenFenZheng"].Text = dic.Get <string>("ShenFenZhengNo");
                            }
                        }
                        else
                        {
                            if (marks["SheJi_MajorName" + index] != null)
                            {
                                marks["SheJi_MajorName" + index].Text = dic.Get <string>("MajorName");
                            }
                            if (marks["SheJi_UserName" + index] != null)
                            {
                                marks["SheJi_UserName" + index].Text = dic.Get <string>("UserName");
                            }
                            index++;
                        }
                    }
                    sql   = @"select a.*,(select top 1 SortIndex from NCRL_Portal..SysEnumeration where Name=a.MajorName and ParentId='b640c40c-e2a9-41a8-bd28-d8ff9d71ff94') as SortIndex
                        ,b.StampNo as QianZhangStampNo,c.StampNo as ShenHeStampNo  from NCRL_SP..ProjectUser a 
                        left join NCRL_SP..Expert b on b.Id=a.QianZhangId 
                        left join NCRL_SP..Expert c on c.Id=a.ShenHeId where a.ProjectId='" + pEnt.Id + "' order by SortIndex asc";
                    dics  = DataHelper.QueryDictList(sql);
                    index = 1;
                    foreach (EasyDictionary dic in dics)
                    {
                        if (marks["ShenTu_MajorName" + index] != null)
                        {
                            marks["ShenTu_MajorName" + index].Text = dic.Get <string>("MajorName");
                        }
                        if (marks["ShenTu_UserName" + index] != null)
                        {
                            marks["ShenTu_UserName" + index].Text = dic.Get <string>("QianZhangName");
                        }
                        if (marks["ShenTu_SealNo" + index] != null)
                        {
                            marks["ShenTu_SealNo" + index].Text = dic.Get <string>("QianZhangStampNo");
                        }
                        if (marks["FuHe_UserName" + index] != null)
                        {
                            marks["FuHe_UserName" + index].Text = dic.Get <string>("ShenHeName");
                        }
                        if (marks["FuHe_SealNo" + index] != null)
                        {
                            marks["FuHe_SealNo" + index].Text = dic.Get <string>("ShenHeStampNo");
                        }
                        index++;
                    }
                    //写入备案登记表信息
                    IList <BeiAn_Project> bapEnts = BeiAn_Project.FindAllByProperty(BeiAn_Project.Prop_ProjectId, pEnt.Id);
                    if (bapEnts.Count > 0)
                    {
                        for (int j = 0; j < marks.Count; j++)
                        {
                            Bookmark mark = marks[j];
                            if (ContainProperty_Object(bapEnts[0], mark.Name))
                            {
                                mark.Text = bapEnts[0].GetValue(mark.Name) + "";
                            }
                        }
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_审查备案登记表.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_shenchabaogao":
                try
                {
                    if (pEnt.ProjectType == "房屋建筑")
                    {
                        srcDoc = new Document(templatepath + "房屋建筑_审查报告.doc");
                    }
                    if (pEnt.ProjectType == "市政工程")
                    {
                        srcDoc = new Document(templatepath + "市政工程_审查报告.doc");
                    }
                    if (pEnt.ProjectType == "基坑支护")
                    {
                        srcDoc = new Document(templatepath + "基坑支护_审查报告.doc");
                    }
                    marks = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        Bookmark mark = marks[j];
                        if (ContainProperty(pEnt, mark.Name))
                        {
                            mark.Text = pEnt.GetValue(mark.Name) + "";
                        }
                    }
                    IList <ShenChaReport> scrEnts = ShenChaReport.FindAllByProperty(ShenChaReport.Prop_ProjectId, pEnt.Id);
                    if (scrEnts.Count > 0)
                    {
                        for (int j = 0; j < marks.Count; j++)
                        {
                            Bookmark mark = marks[j];
                            if (ContainProperty_Object(scrEnts[0], mark.Name))
                            {
                                mark.Text = scrEnts[0].GetValue(mark.Name) + "";
                            }
                        }
                    }
                    if (marks["Layer"] != null)
                    {
                        marks["Layer"].Text = "地上层数:" + pEnt.UpperLayers + (string.IsNullOrEmpty(pEnt.DownLayers) ? "" : "地下层数:" + pEnt.DownLayers);
                    }
                    if (marks["ProjectName1"] != null)
                    {
                        marks["ProjectName1"].Text = pEnt.ProjectName;
                    }
                    if (marks["JianSheUnit1"] != null)
                    {
                        marks["JianSheUnit1"].Text = pEnt.JianSheUnit;
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_审查报告.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_kanchashenchabaogao":
                try
                {
                    srcDoc = new Document(templatepath + "江西省工程勘察审查报告书.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        Bookmark mark = marks[j];
                        if (ContainProperty(pEnt, mark.Name))
                        {
                            mark.Text = pEnt.GetValue(mark.Name) + "";
                        }
                    }
                    IList <ShenChaReport_KanCha> scrkEnts = ShenChaReport_KanCha.FindAllByProperty(ShenChaReport_KanCha.Prop_ProjectId, pEnt.Id);
                    if (scrkEnts.Count > 0)
                    {
                        for (int j = 0; j < marks.Count; j++)
                        {
                            if (ContainProperty_Object(scrkEnts[0], marks[j].Name))
                            {
                                marks[j].Text = scrkEnts[0].GetValue(marks[j].Name) + "";
                            }
                        }
                    }
                    if (marks["ProjectName2"] != null)
                    {
                        marks["ProjectName2"].Text = pEnt.ProjectName;
                    }
                    if (marks["JianSheUnit2"] != null)
                    {
                        marks["JianSheUnit2"].Text = pEnt.JianSheUnit;
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_工程勘察审查报告.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "exportqingkuangjilu":
                try
                {
                    srcDoc = new Document(templatepath + "附件6房屋建筑和市政基础设施工程施工图设计文件审查情况记录.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        Bookmark mark = marks[j];
                        if (ContainProperty(pEnt, mark.Name))
                        {
                            mark.Text = pEnt.GetValue(mark.Name) + "";
                        }
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_审查情况记录.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_shenchahuizong":
                try
                {
                    srcDoc = new Document(templatepath + "审查情况汇总.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        Bookmark mark = marks[j];
                        if (ContainProperty(pEnt, mark.Name))
                        {
                            mark.Text = pEnt.GetValue(mark.Name) + "";
                        }
                    }
                    if (marks["ProjectType2"] != null)
                    {
                        marks["ProjectType2"].Text = pEnt.ProjectType;
                    }
                    if (marks["Layer"] != null)
                    {
                        marks["Layer"].Text = "地上层数:" + pEnt.UpperLayers + (string.IsNullOrEmpty(pEnt.DownLayers) ? "" : "地下层数:" + pEnt.DownLayers);
                    }
                    //找到项目人员 排除勘察专业的
                    sql  = @"select a.*,(select top 1 SortIndex from NCRL_Portal..SysEnumeration where Name=a.MajorName and ParentId='b640c40c-e2a9-41a8-bd28-d8ff9d71ff94') as SortIndex
                        from NCRL_SP..ProjectUser a   where a.ProjectId='" + pEnt.Id + "' order by SortIndex asc";
                    dics = DataHelper.QueryDictList(sql);
                    int index = 1;
                    foreach (EasyDictionary dic in dics)
                    {
                        if (dic.Get <string>("MajorName") != "勘察")
                        {
                            if (marks["MajorName" + index] != null)
                            {
                                marks["MajorName" + index].Text = dic.Get <string>("MajorName");
                            }
                            if (marks["QianZhangName" + index] != null)
                            {
                                marks["QianZhangName" + index].Text = dic.Get <string>("QianZhangName");
                            }
                            index++;
                        }
                    }
                    sql = @"select isnull(sum(QiangTiao),0) from NCRL_SP..ExamineOpinion where ExamineTaskId in (
                        select Id from NCRL_SP..ExamineTask where ProjectId='" + pEnt.Id + "')";
                    if (marks["QiangTiao"] != null)
                    {
                        marks["QiangTiao"].Text = DataHelper.QueryValue(sql) + "";
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_审查情况汇总.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_shenchahuizong_kancha":    //审查情况汇总表_工程勘察
                try
                {
                    srcDoc = new Document(templatepath + "审查情况汇总表_工程勘察.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        if (ContainProperty(pEnt, marks[j].Name))
                        {
                            marks[j].Text = pEnt.GetValue(marks[j].Name) + "";
                        }
                    }
                    if (marks["QianZhangName"] != null)    //找到勘察专业的签章专家
                    {
                        IList <ProjectUser> puEnts = ProjectUser.FindAllByProperties(ProjectUser.Prop_ProjectId, pEnt.Id, ProjectUser.Prop_MajorName, "勘察");
                        if (puEnts.Count > 0)
                        {
                            marks["QianZhangName"].Text = puEnts[0].QianZhangName;
                        }
                    }
                    if (marks["QiangTiao"] != null)    //找到勘察专业的强条
                    {
                        IList <ExamineTask> etEnts = ExamineTask.FindAllByProperties(ExamineTask.Prop_MajorName, "勘察", ExamineTask.Prop_ProjectId, pEnt.Id);
                        if (etEnts.Count > 0)
                        {
                            sql = "select isnull(sum(QiangTiao),0) from NCRL_SP..ExamineOpinion where ExamineTaskId='" + etEnts[0].Id + "'";
                            marks["QiangTiao"].Text = DataHelper.QueryValue <Int32>(sql) + "";
                        }
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_工程勘察审查情况汇总表.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_kangzhen":
                try
                {
                    srcDoc = new Document(templatepath + "抗震设防监管表.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        if (ContainProperty(pEnt, marks[j].Name))
                        {
                            marks[j].Text = pEnt.GetValue(marks[j].Name) + "";
                        }
                    }
                    IList <KangZhen_Project> kzpEnts = KangZhen_Project.FindAllByProperty(KangZhen_Project.Prop_ProjectId, pEnt.Id);
                    if (kzpEnts.Count > 0)
                    {
                        for (int j = 0; j < marks.Count; j++)
                        {
                            if (ContainProperty_Object(kzpEnts[0], marks[j].Name))
                            {
                                marks[j].Text = kzpEnts[0].GetValue <string>(marks[j].Name);
                            }
                        }
                    }
                    if (pEnt.Property == "新建" && marks["XinJian"] != null)
                    {
                        marks["XinJian"].Text = "√";
                    }
                    if (pEnt.Property == "改建" && marks["GaiJian"] != null)
                    {
                        marks["GaiJian"].Text = "√";
                    }
                    if (pEnt.Property == "扩建" && marks["KuoJian"] != null)
                    {
                        marks["KuoJian"].Text = "√";
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_抗震设防专项审查监管表.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_zhongshenyijianbiao":
                try
                {
                    srcDoc = new Document(templatepath + "附件5_终审意见表.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    for (int j = 0; j < marks.Count; j++)
                    {
                        if (ContainProperty(pEnt, marks[j].Name))
                        {
                            marks[j].Text = pEnt.GetValue(marks[j].Name) + "";
                        }
                    }
                    IList <ZhongShenOpinion_Project> zsopEnts = ZhongShenOpinion_Project.FindAllByProperty(ZhongShenOpinion_Project.Prop_ProjectId, pEnt.Id);
                    if (zsopEnts.Count > 0)
                    {
                        for (int j = 0; j < marks.Count; j++)
                        {
                            if (ContainProperty_Object(zsopEnts[0], marks[j].Name))
                            {
                                marks[j].Text = zsopEnts[0].GetValue(marks[j].Name) + "";
                            }
                        }
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_终审意见表.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;

            case "export_subproject":    //导出子项
                try
                {
                    srcDoc = new Document(templatepath + "子项目明细表.doc");
                    marks  = srcDoc.Range.Bookmarks;
                    IList <SubProject> suEnts = SubProject.FindAllByProperty(SubProject.Prop_ProjectId, pEnt.Id);
                    for (int j = 0; j < suEnts.Count; j++)
                    {
                        foreach (PropertyInfo pi in SubProject.AllProperties)
                        {
                            if (marks[pi.Name + (j + 1)] != null)
                            {
                                marks[pi.Name + (j + 1)].Text = suEnts[j].GetValue(pi.Name) + "";
                            }
                        }
                    }
                    if (marks["ProjectName"] != null)
                    {
                        marks["ProjectName"].Text = pEnt.ProjectName;
                    }
                    filename = pEnt.ProjectName.Replace("#", "") + "_子项目明细表.doc";
                    srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename);
                    UpdateFileItem(filename);
                    Response.Write("{success:true}");
                }
                catch (Exception ex)
                {
                    Response.Write("{success:false}");
                }
                Response.End();
                break;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string              action = Request["action"];
            string              id     = Request["id"];
            string              userid = Request["userid"];
            string              sql    = "";
            DataTable           dt     = null;
            ProjectAttendance   paEnt  = null;
            IList <ProjectUser> puEnts = null;

            if (!string.IsNullOrEmpty(id))
            {
                paEnt = ProjectAttendance.Find(id);
            }
            switch (action)
            {
            case "loadproject":
                sql = @"select Id as ProjectId,PManagerId,ProjectName,PManagerName,BelongDeptId,BelongDeptName from NCRL_SP..Project";
                dt  = DataHelper.QueryDataTable(sql);
                string data_prj = JsonHelper.GetJsonString(dt);
                sql = "select value as year from NCRL_Portal..SysEnumeration where ParentId='058fbee9-0a9a-4b25-b343-ea8c05396632' order by SortIndex asc";
                dt  = DataHelper.QueryDataTable(sql);
                string data_year = JsonHelper.GetJsonString(dt);
                sql = "select value as month from NCRL_Portal..SysEnumeration where ParentId='b25e537b-34e3-4437-87af-692e00facd73' order by SortIndex asc";
                dt  = DataHelper.QueryDataTable(sql);
                string data_month = JsonHelper.GetJsonString(dt);
                Response.Write("{'rows':" + data_prj + ",year:" + data_year + ",month:" + data_month + "}");
                Response.End();
                break;

            case "save":
                JObject jo = JsonHelper.GetObject <JObject>(Request["formdata"]);
                //有可能具体该年月的项目考勤主表已经存在
                sql = "select * from NCRL_SP..ProjectAttendance where ProjectId='{0}' and Year='{1}' and Month='{2}'";
                sql = string.Format(sql, jo.Value <string>("ProjectId"), jo.Value <string>("Year"), jo.Value <string>("Month"));
                dt  = DataHelper.QueryDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    paEnt        = ProjectAttendance.Find(dt.Rows[0]["Id"]);
                    paEnt.Remark = jo.Value <string>("Remark");
                    paEnt.DoUpdate();
                }
                else
                {
                    paEnt = JsonHelper.GetObject <ProjectAttendance>(Request["formdata"]);
                    paEnt.DoCreate();
                }
                //创建完项目阶段考勤后 自动创建本阶段项目所属部门考勤和公司考勤
                //IList<CmpAttendance> caEnts = CmpAttendance.FindAllByProperties(CmpAttendance.Prop_Year, paEnt.Year, CmpAttendance.Prop_Month, paEnt.Month);
                //if (caEnts.Count == 0)
                //{
                //    CmpAttendance caEnt = new CmpAttendance();
                //    caEnt.Year = paEnt.Year;
                //    caEnt.Month = paEnt.Month;
                //    caEnt.DoCreate();
                //}
                //表单信息创建或者更新完毕后调取考核明细
                sql = "select * from  NCRL_SP..PrjAttendanceDetail  where ProjectAttendanceId='" + paEnt.Id + "' order by UserId asc";
                dt  = DataHelper.QueryDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    //如果是首次创建没有考勤明细的时候
                    sql = "select UserId,UserName from NCRL_SP..ProjectUser where ProjectId='" + paEnt.ProjectId + "' order by UserId asc";
                    dt  = DataHelper.QueryDataTable(sql);
                }
                string title   = paEnt.ProjectName + paEnt.Year + "年" + paEnt.Month + "月考勤表";
                int    runyear = 0;
                if ((paEnt.Year % 4 == 0 && paEnt.Year % 100 != 0) || paEnt.Year % 400 == 0)
                {
                    runyear = 1;
                }
                Response.Write("{success:true,month:'" + paEnt.Month + "',runyear:" + runyear + ",Id:'" + paEnt.Id + "',detail:" + JsonHelper.GetJsonStringFromDataTable(dt) + ",title:'" + title + "'}");
                Response.End();
                break;

            case "loadform":
                paEnt = ProjectAttendance.Find(id);
                Response.Write("{success:true,data:" + JsonHelper.GetJsonString(paEnt) + "}");
                Response.End();
                break;

            case "updatedetail":
                string result = Request["SignType"];
                paEnt = ProjectAttendance.Find(id);
                sql   = "select * from NCRL_SP..PrjAttendanceDetail where ProjectAttendanceId='" + paEnt.Id + "' and UserId='" + Request["UserId"] + "'";
                dt    = DataHelper.QueryDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    sql = "insert into NCRL_SP..PrjAttendanceDetail (Id,ProjectAttendanceId,UserId,UserName,Year,Month," + Request["day"] + ") values('" + Guid.NewGuid() + "','" + paEnt.Id + "','" + Request["UserId"] + "','" + Request["UserName"] + "','" + paEnt.Year + "','" + paEnt.Month + "','" + Request["SignType"] + "')";
                }
                else
                {
                    //如果先前同一个字段标记的是正常上班,再次点正常上班时,清空该字段
                    if (dt.Rows[0][Request["day"]] + "" == Request["SignType"])
                    {
                        sql    = "update NCRL_SP..PrjAttendanceDetail set " + Request["day"] + "=null where Id='" + dt.Rows[0]["Id"] + "'";
                        result = "";
                    }
                    else
                    {
                        sql    = "update NCRL_SP..PrjAttendanceDetail set " + Request["day"] + "='" + Request["SignType"] + "' where Id='" + dt.Rows[0]["Id"] + "'";
                        result = Request["SignType"];
                    }
                }
                DataHelper.ExecSql(sql);
                //插入考勤日志,为生成人员月度考勤提供基础数据
                sql = "insert into NCRL_SP..AttendanceLog (Id,ProjectAttendanceId,UserId,UserName,Field,AttendanceType,CreateId,CreateName,CreateTime) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',GETDATE()) ";
                sql = string.Format(sql, Guid.NewGuid(), paEnt.Id, Request["UserId"], Request["UserName"], Request["day"], result, Aim.Portal.PortalService.CurrentUserInfo.UserID, Aim.Portal.PortalService.CurrentUserInfo.Name);
                DataHelper.ExecSql(sql);

                Response.Write("{success:true,result:'" + result + "'}");
                Response.End();
                break;

            case "delete":
                sql = "delete NCRL_SP..ProjectAttendanceDetail where UserId='{0}' and ProjectAttendanceId='{1}' ";
                sql = string.Format(sql, userid, id);
                DataHelper.ExecSql(sql);
                puEnts = ProjectUser.FindAllByProperties(ProjectUser.Prop_UserId, userid, ProjectUser.Prop_ProjectId, paEnt.ProjectId);
                if (puEnts.Count > 0)
                {
                    puEnts[0].DoDelete();
                }
                break;

            case "updateprojectuser":
                puEnts = ProjectUser.FindAllByProperties(ProjectUser.Prop_UserId, userid, ProjectUser.Prop_ProjectId, paEnt.ProjectId);
                if (puEnts.Count == 0)
                {
                    ProjectUser puEnt = new ProjectUser();
                    puEnt.UserId    = userid;
                    puEnt.UserName  = Request["username"];
                    puEnt.ProjectId = paEnt.ProjectId;
                    puEnt.DoCreate();
                }
                break;
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string                action  = Request["action"];
            string                sql     = "";
            DataTable             dt      = null;
            ChouJin               cjEnt   = null;
            ShouKuan              skEnt   = null;
            ChouJinDetail         cjdEnt  = null;
            ChouJinResult         cjrEnt  = null;
            string                id      = Request["id"];
            IList <ShouKuan>      skEnts  = null;
            IList <ChouJinDetail> cjdEnts = null;
            IList <ChouJinResult> cjrEnts = null;

            switch (action)
            {
            case "loadyear":
                sql = "select value as year from NCRL_Portal..SysEnumeration where ParentId='058fbee9-0a9a-4b25-b343-ea8c05396632' order by SortIndex asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "loadmonth":
                sql = "select value as month from NCRL_Portal..SysEnumeration where ParentId='b25e537b-34e3-4437-87af-692e00facd73' order by SortIndex asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "create":
                cjEnt = JsonHelper.GetObject <ChouJin>(Request["formdata"]);
                cjEnt.DoCreate();
                Response.Write("{success:true,id:'" + cjEnt.Id + "'}");
                Response.End();
                break;

            case "update":
                cjEnt = JsonHelper.GetObject <ChouJin>(Request["formdata"]);
                ChouJin        originalEnt = ChouJin.Find(cjEnt.Id);
                EasyDictionary dic         = JsonHelper.GetObject <EasyDictionary>(Request["formdata"]);
                originalEnt = DataHelper.MergeData <ChouJin>(originalEnt, cjEnt, dic.Keys);
                originalEnt.DoUpdate();
                Response.Write("{success:true,id:'" + cjEnt.Id + "'}");
                Response.End();
                break;

            case "loadform":
                cjEnt = ChouJin.Find(id);
                Response.Write("{success:true,data:" + JsonHelper.GetJsonString(cjEnt) + "}");
                Response.End();
                break;

            case "loadshoukuan":
                skEnts = ShouKuan.FindAllByProperty(ShouKuan.Prop_ShouKuanDate, ShouKuan.Prop_ChouJinId, id);
                if (skEnts.Count == 0)
                {
                    cjEnt = ChouJin.Find(id);
                    sql   = @"select a.Id,a.ProjectId,a.InvoiceId,a.ShouKuanAmount,a.ShouKuanDate,a.ShiJiShouFei,
                        a.YiFenPercent,a.ChouJinAmount,b.ProjectName,c.InvoiceNo
                        from NCRL_SP..ShouKuan a left join NCRL_SP..Project b on a.ProjectId=b.Id
                        left join NCRL_SP..Invoice c on a.InvoiceId=c.Id
                        where YiFenPercent is null and  year(ShouKuanDate)='" + cjEnt.BelongYear + "' and month(ShouKuanDate)='" + (Convert.ToInt32(cjEnt.BelongMonth) - 1) + "' and isnull(a.Status,'')<>'已作废' order by ShouKuanDate asc";
                }
                else
                {
                    sql = @"select a.Id,a.ProjectId,a.InvoiceId,a.ShouKuanAmount,a.ShouKuanDate,a.ShiJiShouFei,
                        a.YiFenPercent,a.ChouJinAmount,b.ProjectName,c.InvoiceNo
                        from NCRL_SP..ShouKuan a left join NCRL_SP..Project b on a.ProjectId=b.Id
                        left join NCRL_SP..Invoice c on a.InvoiceId=c.Id
                        where ChouJinId='" + id + "'  order by a.ShouKuanDate asc";
                }
                dt = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "updateshoukuan":
                string   shoukuanids = Request["shoukuanids"];
                string[] idarray     = shoukuanids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string str in idarray)
                {
                    skEnt           = ShouKuan.Find(str);
                    skEnt.ChouJinId = id;
                    skEnt.DoUpdate();
                }
                //顺便把酬金分配明细的store构建后送到前端  为动态页面的生成提供数据基础
                skEnts = ShouKuan.FindAllByProperty(ShouKuan.Prop_ShouKuanDate, ShouKuan.Prop_ChouJinId, id);
                DataTable dt2 = new DataTable();
                //构建表格列
                // dc = new DataColumn("MajorName");
                //dt2.Columns.Add(dc);
                DataColumn dc = new DataColumn("UserId");
                dt2.Columns.Add(dc);
                dc = new DataColumn("UserName");
                dt2.Columns.Add(dc);
                dc = new DataColumn("StageAmount");
                dt2.Columns.Add(dc);
                foreach (ShouKuan tempEnt in skEnts)
                {
                    dc = new DataColumn(tempEnt.Id + "@A");
                    dt2.Columns.Add(dc);
                    dc = new DataColumn(tempEnt.Id + "@B");
                    dt2.Columns.Add(dc);
                    dc = new DataColumn(tempEnt.Id + "@C");
                    dt2.Columns.Add(dc);
                }       //构建表格行  先构建前面的特殊5行
                DataRow dr1  = dt2.NewRow();
                DataRow dr2  = dt2.NewRow();
                DataRow dr3  = dt2.NewRow();
                DataRow dr4  = dt2.NewRow();
                DataRow dr5  = dt2.NewRow();
                Project pEnt = null;
                dr1["UserName"] = "******"; dr2["UserName"] = "******"; dr3["UserName"] = "******"; dr4["UserName"] = "******"; dr5["UserName"] = "******";
                foreach (ShouKuan tempEnt in skEnts)
                {
                    pEnt = Project.Find(tempEnt.ProjectId);
                    dr1[tempEnt.Id + "@A"] = pEnt.ProjectName;
                    dr1[tempEnt.Id + "@C"] = tempEnt.ShouKuanAmount;    //获取收款金额
                    if (!string.IsNullOrEmpty(pEnt.DelegateInfoId))
                    {
                        dr2[tempEnt.Id + "@A"] = DelegateInfo.Find(pEnt.DelegateInfoId).DelegateName;    //第二行收款记录第一列显示窗口名称 第三列显示窗口比例
                    }
                    dr2[tempEnt.Id + "@B"] = tempEnt.Id;
                    dr2[tempEnt.Id + "@C"] = pEnt.ChuangKouBiLi;    //将收款记录的ID存到第二行的第三列上。便于前台获取
                    dr3[tempEnt.Id + "@C"] = tempEnt.ShiJiShouFei;  //第三行收款记录第三列存显示实际收费 即收款金额-收款金额*窗口比例
                    dr4[tempEnt.Id + "@C"] = tempEnt.ChouJinAmount;
                    dr5[tempEnt.Id + "@A"] = tempEnt.YiFenPercent;
                    dr5[tempEnt.Id + "@B"] = 100;
                }
                dt2.Rows.Add(dr1); dt2.Rows.Add(dr2); dt2.Rows.Add(dr3); dt2.Rows.Add(dr4); dt2.Rows.Add(dr5);
                //所有的专家
                IList <Expert> expEnts = Expert.FindAllByProperty(Expert.Prop_SortIndex, Expert.Prop_Status, "T");
                foreach (Expert tEnt in expEnts)
                {
                    DataRow dr = dt2.NewRow();
                    dr["UserId"]      = tEnt.Id;
                    dr["UserName"]    = tEnt.UserName;
                    cjrEnts           = ChouJinResult.FindAllByProperties(ChouJinResult.Prop_ChouJinId, id, ChouJinResult.Prop_ExpertId, tEnt.Id);
                    dr["StageAmount"] = cjrEnts.Count == 0 ? "" : cjrEnts[0].StageAmount + "";
                    foreach (ShouKuan shoukuanEnt in skEnts)
                    {
                        cjdEnts = ChouJinDetail.FindAllByProperties(ChouJinDetail.Prop_ChouJinId, id, ChouJinDetail.Prop_ExpertId, tEnt.Id, ChouJinDetail.Prop_ShouKuanId, shoukuanEnt.Id);
                        IList <ProjectUser> puEnts = ProjectUser.FindAllByProperties(ProjectUser.Prop_ProjectId, shoukuanEnt.ProjectId, ProjectUser.Prop_UserId, tEnt.Id);
                        dr[shoukuanEnt.Id + "@A"] = puEnts.Count > 0 ? "√" : "";
                        dr[shoukuanEnt.Id + "@B"] = cjdEnts.Count > 0 ? cjdEnts[0].ChouJinPercent : null;
                        dr[shoukuanEnt.Id + "@C"] = cjdEnts.Count > 0 ? cjdEnts[0].ChouJinAmount : null;
                    }
                    dt2.Rows.Add(dr);
                }
                Response.Write("{success:true,rows:" + JsonHelper.GetJsonStringFromDataTable(dt2) + "}");
                Response.End();
                break;

            case "savechoujindetail":
                cjdEnts = ChouJinDetail.FindAllByProperties(ChouJinDetail.Prop_ChouJinId, id, ChouJinDetail.Prop_ExpertId, Request["expertid"], ChouJinDetail.Prop_ShouKuanId, Request["shoukuanid"]);
                if (cjdEnts.Count == 0)
                {
                    if (Convert.ToDecimal(Request["choujinpercent"]) > 0)
                    {
                        cjdEnt                = new ChouJinDetail();
                        cjdEnt.ChouJinId      = id;
                        cjdEnt.ExpertId       = Request["expertid"];
                        cjdEnt.UserName       = Request["username"];
                        cjdEnt.ShouKuanId     = Request["shoukuanid"];
                        cjdEnt.ChouJinPercent = Convert.ToDecimal(Request["choujinpercent"]);
                        cjdEnt.ChouJinAmount  = Convert.ToDecimal(Request["choujinamount"]);
                        cjdEnt.IfCanYu        = Request["ifcanyu"];
                        cjdEnt.DoCreate();    //酬金明细保存后,同时更新酬金结果 、收款记录的已分百分比
                        skEnt = ShouKuan.Find(Request["shoukuanid"]);
                        skEnt.YiFenPercent = Convert.ToDecimal(Request["yifenpercent"]);
                        skEnt.DoUpdate();
                    }
                }
                else
                {
                    if (Convert.ToDecimal(Request["choujinpercent"]) > 0)
                    {
                        cjdEnt = cjdEnts[0];
                        cjdEnt.ChouJinPercent = Convert.ToDecimal(Request["choujinpercent"]);
                        cjdEnt.ChouJinAmount  = Convert.ToDecimal(Request["choujinamount"]);
                        cjdEnt.IfCanYu        = Request["ifcanyu"];
                        cjdEnt.DoUpdate();
                        skEnt = ShouKuan.Find(Request["shoukuanid"]);
                        skEnt.YiFenPercent = Convert.ToDecimal(Request["yifenpercent"]);
                        skEnt.DoUpdate();
                    }
                    else
                    {
                        cjdEnts[0].DoDelete();
                    }
                }
                cjrEnts = ChouJinResult.FindAllByProperties(ChouJinResult.Prop_ExpertId, Request["expertid"], ChouJinResult.Prop_ChouJinId, id);
                if (cjrEnts.Count == 0)
                {
                    cjrEnt             = new ChouJinResult();
                    cjrEnt.ExpertId    = Request["expertid"];
                    cjrEnt.UserName    = Request["username"];
                    cjrEnt.ChouJinId   = id;
                    cjrEnt.StageAmount = Convert.ToDecimal(Request["stageamount"]);
                    cjrEnt.DoCreate();
                }
                else
                {
                    if (Convert.ToDecimal(Request["stageamount"]) > 0)
                    {
                        cjrEnt             = cjrEnts[0];
                        cjrEnt.StageAmount = Convert.ToDecimal(Request["stageamount"]);
                        cjrEnt.DoUpdate();
                    }
                    else
                    {
                        cjrEnts[0].DoDelete();
                    }
                }
                break;

            case "loadchoujinresult":    //默认调整金额==分配金额
                sql   = @"select a.Id as ExpertId,a.UserName,b.Remark,b.StageAmount,isnull(AdjustAmount,StageAmount) AdjustAmount from NCRL_SP..Expert a
                          left join (select * from  NCRL_SP..ChouJinResult where ChouJinId='{0}') b on a.Id=b.ExpertId";
                sql   = string.Format(sql, id);
                dt    = DataHelper.QueryDataTable(sql);
                cjEnt = ChouJin.Find(id);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + ",title:'" + cjEnt.BelongYear + "年" + cjEnt.BelongMonth + "月专家酬金'}");
                Response.End();
                break;

            case "adjustresult":
                cjrEnts = ChouJinResult.FindAllByProperties(ChouJinResult.Prop_ChouJinId, id, ChouJinResult.Prop_ExpertId, Request["expertid"]);
                if (cjrEnts.Count == 0)
                {
                    cjrEnt              = new ChouJinResult();
                    cjrEnt.ExpertId     = Request["expertid"];
                    cjrEnt.UserName     = Request["username"];
                    cjrEnt.ChouJinId    = id;
                    cjrEnt.AdjustAmount = Convert.ToDecimal(Request["adjustamount"]);
                    cjrEnt.Remark       = Request["remark"];
                    cjrEnt.DoCreate();
                }
                else
                {
                    cjrEnt = cjrEnts[0];
                    cjrEnt.AdjustAmount = Convert.ToDecimal(Request["adjustamount"]);
                    cjrEnt.Remark       = Request["remark"];
                    cjrEnt.DoUpdate();
                }
                break;

            case "loadshoukuan_unfenpei":
                sql = @"select a.Id,a.ProjectId,a.InvoiceId,a.ShouKuanAmount,a.ShouKuanDate,a.ShiJiShouFei,
                        a.YiFenPercent,a.ChouJinAmount,b.ProjectName,c.InvoiceNo from NCRL_SP..ShouKuan a                        
                        left join NCRL_SP..Project b on a.ProjectId=b.Id
                        left join NCRL_SP..Invoice c on a.InvoiceId=c.Id
                        where isnull(ChouJinId,'')='' order by a.ShouKuanDate asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;
            }
        }