コード例 #1
0
ファイル: DataTable_Action.ashx.cs プロジェクト: kang740/-
        /// <summary>
        /// ---------------操作响应-------Server Side-----
        /// 根据上传参数,执行相应操作,返回是否成功
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            bool b_result = false;
            //上传的参数
            //data: {tableName:str_tableName, modelClassName:str_modelClassName, actionType: str_actType, actionObj: str_actObj },
            string tableName      = context.Request.Params["tableName"];      //表名
            string modelClassName = context.Request.Params["modelClassName"]; //类名
            string action         = context.Request.Params["actionType"];     //操作:删除对象、删除列表、添加对象、修改对象
            string targetObject   = context.Request.Params["actionObj"];      //对象json或对象数组

            //缺少参数,返回错误
            if ((tableName == null || tableName == "") ||
                (modelClassName == null || modelClassName == ""))
            {
                context.Response.Write("{'success':" + "false" + "}");
            }
            //视图改成表操作
            //V开头的视图改成T开头
            if (tableName.Substring(0, 1) == "v")
            {
                tableName = "t" + tableName.Substring(1);
            }
            //v开头的模型去掉v
            if (modelClassName.Substring(0, 1) == "v")
            {
                modelClassName = modelClassName.Substring(1);
            }

            AngelData OperatingData = new AngelData(tableName, modelClassName);     //"Test","Test"--操作数据库数据方法

            context.Response.ContentType = "text/plain";

            //对象是否存在(id)
            if (action == "isObjectExist")
            {
                b_result = OperatingData.ObjectExistById(targetObject);
                // 对于用户表,还要检查同一企业的用户名是否已存在
            }

            string AdminName = AngelUtils.GetCookie("AgeRememberName") == null ? "" : AngelUtils.GetCookie("AgeRememberName").ToString();

            if ((AdminName == "") || (AdminName == null))
            {
                context.Response.Write("{'success':" + "false" + "}");
                return;
            }

            //删除对象(id)
            switch (tableName)
            {
            case "t_product":
                //Product pro1 = TestData.GetObject_ById<Product>(targetObject);
                //if (action == "deleteObject")
                //{
                //    C_xData quolinedata = new C_xData("t_quoteline", "Quoteline");
                //    quolinedata.SetConditionString(" Product_ID='" + pro1.Product_ID + "' and Corp_ID='" + str_Corp_ID + "'");
                //    C_xData orderlinedata = new C_xData("t_orderline", "Orderline");
                //    orderlinedata.SetConditionString(" Product_ID='" + pro1.Product_ID + "' and Corp_ID='" + str_Corp_ID + "'");
                //    bool isProduct = quolinedata.Condition_DataExist();
                //    bool isProduct1 = orderlinedata.Condition_DataExist();
                //    if (isProduct || isProduct1)
                //    {
                //        b_result = false;
                //    }
                //    else
                //    {
                //        b_result = TestData.DeleteObjectById(targetObject);
                //    }
                //}
                break;

            default:
                if (action == "deleteObject")
                {
                    b_result = OperatingData.DeleteObjectById(targetObject);
                }
                break;
            }

            //删除多个对象(id[])
            if (action == "deleteObjects")
            {
                b_result = OperatingData.DeleteObjectsById(targetObject);
            }

            //批量审批多个对象(id[])
            if (action == "reviewObjects")
            {
                b_result = OperatingData.setObjectsAttributById(targetObject, "Status", "审批通过");
            }

            //审批一个对象
            if (action == "reviewObject")
            {
                b_result = OperatingData.setObjectAttributById(targetObject, "Status", "审批通过");
            }


            //更新对象(json)
            if (action == "updateObject")
            {
                // 读取Json数据
                Angel_DataJson.getValuelistByJsonString(targetObject, OperatingData.lst_colId, out OperatingData.lst_Value);
                //if (tableName != "t_corp")
                //{
                //    // 写入企业代码
                //    for (int i = 0; i < TestData.lst_colId.Count; i++)
                //        if (TestData.lst_colId[i] == "Corp_ID") TestData.lst_Value[i] = str_Corp_ID;
                //}
                b_result = OperatingData.UpdateData();
            }
            //插入新对象(json)
            if (action == "insertObject")
            {
                //if (TestData.lst_colId[4] == "PassMd5")
                //    TestData.lst_Value[4] =


                // 读取Json数据
                Angel_DataJson.getValuelistByJsonString(targetObject, OperatingData.lst_colId, out OperatingData.lst_Value);

                // 如果是用户表,检查User_ID是否重名
                bool   isUserExist = false;
                string str_user_id = "";



                if (isUserExist)
                {
                    b_result = false;
                }
                else
                {
                    b_result = OperatingData.InsertData();  // 插入数据
                }
            }
            //返回结果
            if (b_result)
            {
                context.Response.Write("{'success':" + "true" + "}");
            }
            else
            {
                context.Response.Write("{'success':" + "false" + "}");
            }
        }
コード例 #2
0
ファイル: SystemInfo.ashx.cs プロジェクト: kang740/-
        public void ProcessRequest(HttpContext context)
        {
            Business.Angel_System_Parameter PBLL = new Business.Angel_System_Parameter();
            string ActionName = context.Request.Params["action"];

            //根据相应操作进行处理
            switch (ActionName)
            {
            case "fromJson":
                AngelRM.Model.Angel_Siteconfig WebSiteInfo = new Business.Angel_Siteconfig().loadConfig();
                string fjson = Angel_DataJson.Object2Json <AngelRM.Model.Angel_Siteconfig>(WebSiteInfo);
                context.Response.Write(fjson);
                break;

            case "Savewebsiteinfo":
                AngelRM.Model.Angel_Siteconfig SiteInfo = new Model.Angel_Siteconfig();
                SiteInfo.Websitename        = context.Request.Params["Websitename"];
                SiteInfo.Websiteurl         = context.Request.Params["Websiteurl"];
                SiteInfo.Websitelogo        = context.Request.Params["Websitelogo"];
                SiteInfo.Websitecompany     = context.Request.Params["Websitecompany"];
                SiteInfo.Websiteaddress     = context.Request.Params["Websiteaddress"];
                SiteInfo.Websitetel         = context.Request.Params["Websitetel"];
                SiteInfo.Websitefax         = context.Request.Params["Websitefax"];
                SiteInfo.Websitemail        = context.Request.Params["Websitemail"];
                SiteInfo.Websitetitle       = context.Request.Params["Websitetitle"];
                SiteInfo.Websitedescription = context.Request.Params["Websitedescription"];
                SiteInfo.Websitecopyright   = context.Request.Params["Websitecopyright"];
                SiteInfo.Websitepath        = context.Request.Params["Websitepath"];
                SiteInfo.Websiteadminpath   = context.Request.Params["Websiteadminpath"];
                SiteInfo.Islogstatus        = Convert.ToInt32(context.Request.Params["Islogstatus"]);
                SiteInfo.Websitestatus      = Convert.ToInt32(context.Request.Params["Websitestatus"]);
                SiteInfo.Websiteclosereason = context.Request.Params["Websiteclosereason"];
                AngelRM.Business.Angel_Siteconfig bll = new Business.Angel_Siteconfig();
                bll.saveConifg(SiteInfo);
                context.Response.Write("{\"success\":true}");
                break;

            case "AddSysparameter":
                AngelRM.Model.Angel_System_Parameter parameter = new Model.Angel_System_Parameter();
                parameter.ParaID   = context.Request.Params["ParaID"];
                parameter.ParaName = context.Request.Params["ParaName"];
                parameter.Data     = context.Request.Params["hidData"];
                if (parameter.ParaID == "" || parameter.ParaID == null || parameter.ParaName == "" || parameter.ParaName == null || parameter.Data == "" || parameter.Data == null)
                {
                    context.Response.Write("{\"success\":false}");
                }
                bool isParaID = PBLL.IsParaIDDataExist(parameter.ParaID);
                if (!isParaID)
                {
                    bool iscount = PBLL.Add(parameter);
                    if (iscount)
                    {
                        context.Response.Write("{\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"success\":false}");
                    }
                }
                else
                {
                    context.Response.Write("{\"success\":false}");
                }
                break;

            case "UpSysparameter":
                AngelRM.Model.Angel_System_Parameter parameteru = new Model.Angel_System_Parameter();
                parameteru.id       = Convert.ToInt32(context.Request.Params["id"]);
                parameteru.ParaID   = context.Request.Params["ParaID"];
                parameteru.ParaName = context.Request.Params["ParaName"];
                parameteru.Data     = context.Request.Params["hidData"];
                parameteru.IsView   = "1";
                if (parameteru.id < 1 || parameteru.ParaID == null || parameteru.ParaName == "" || parameteru.ParaName == null || parameteru.Data == "" || parameteru.Data == null)
                {
                    context.Response.Write("{\"success\":false}");
                }
                bool isupdate = PBLL.Update(parameteru);
                if (isupdate)
                {
                    context.Response.Write("{\"success\":true}");
                }
                else
                {
                    context.Response.Write("{\"success\":false}");
                }
                break;

            case "DelDB":
                string idd = context.Request.Params["id"];
                if (idd != "")
                {
                    bool isdelete = PBLL.Delete(idd);
                    if (isdelete)
                    {
                        context.Response.Write("{\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"success\":false}");
                    }
                }
                else
                {
                    context.Response.Write("{\"success\":false}");
                }
                break;

            default:
                context.Response.Write("{\"success\":false}");
                break;
            }
        }