Ejemplo n.º 1
0
        private void getOrgList(HttpContext context)
        {
            string json = "";

            try
            {
                List <TBL_ORGANIZATION> orgList = oBLL.GetList(" a.organizationtype='C70CEDCC-FB20-436E-B35A-AA5A7BD8C488'   or a.organizationtype='FFA21F13-BD0C-4312-BDAB-952C78DC39EE' order by organizationname  ").ToList <TBL_ORGANIZATION>();
                json = JsonConvert.SerializeObject(orgList);
                json = "{IsSuccess:'true',Message:'" + json + "'}";
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'服务器交互失败!'}";
            }

            json = JsonConvert.SerializeObject(json);

            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Ejemplo n.º 2
0
        private void add(HttpContext context)
        {
            string           json = "";
            TBL_ORGANIZATION to   = new TBL_ORGANIZATION();

            to.organizationid   = System.Guid.NewGuid().ToString().ToUpper();
            to.organizationname = context.Request["organizationname"];
            to.organizationtype = context.Request["organizationtype"];
            to.parentid         = context.Request["parentid"];
            to.orglevel         = context.Request["orglevel"];

            try
            {
                List <TBL_ORGANIZATION> orgList = oBLL.GetList("  organizationname='" + to.organizationname + "' ").ToList <TBL_ORGANIZATION>();

                if (orgList.Count > 0)
                {
                    json = "{IsSuccess:'false',Message:'部门名称已经存在!'}";
                }
                else
                {
                    if (oBLL.Insert(to))
                    {
                        //为专业主管部门创建资金账户
                        if (to.organizationtype == "B933AF9E-B57E-40F5-9284-E24BE8EA21FF")
                        {
                            TBL_CAPITALACCOUNT tca = new TBL_CAPITALACCOUNT();
                            tca.capitalaccountid   = System.Guid.NewGuid().ToString().ToUpper();
                            tca.capitalaccounttype = "E483C545-362D-47CF-AEE3-4E3B22E9F277";
                            tca.organizationid     = to.organizationid;
                            tca.balance            = 0;
                            cBLL.Insert(tca);
                        }

                        //为材料使用单位创建资金账户
                        if (to.organizationtype == "FFA21F13-BD0C-4312-BDAB-952C78DC39EE")
                        {
                            TBL_CAPITALACCOUNT tca = new TBL_CAPITALACCOUNT();
                            tca.capitalaccountid   = System.Guid.NewGuid().ToString().ToUpper();
                            tca.capitalaccounttype = "9BF8F1BE-9074-47B1-9123-B3486B65871D";
                            tca.organizationid     = to.organizationid;
                            tca.balance            = 0;
                            cBLL.Insert(tca);
                        }


                        json = "{IsSuccess:'true',Message:'保存成功!',id:'" + to.organizationid + "'}";
                    }
                    else
                    {
                        json = "{IsSuccess:'false',Message:'保存失败!'}";
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'服务器交互失败!'}";
            }
            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.Response.End();
        }