コード例 #1
0
ファイル: CRM_product.ashx.cs プロジェクト: chuing/Push114CRM
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_product ccp = new BLL.CRM_product();
            Model.CRM_product model = new Model.CRM_product();

            BLL.hr_employee emp = new BLL.hr_employee();
            int emp_id = int.Parse(request.Cookies["UserID"].Value);
            DataSet dsemp = emp.GetList("id=" + emp_id);
            string empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string uid = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "save")
            {
                model.category_id = int.Parse(request["T_product_category_val"]);
                model.category_name = PageValidate.InputText(request["T_product_category"], 255);
                model.product_name = PageValidate.InputText(request["T_product_name"], 255);
                model.specifications = PageValidate.InputText(request["T_specifications"], 255);
                model.unit = PageValidate.InputText(request["T_product_unit"], 255);
                model.remarks = PageValidate.InputText(request["T_remarks"], 255);
                model.pway_content = PageValidate.InputText(request["T_pway_content"], 255);
                model.price = decimal.Parse(request["T_price"].ToString());
                model.base_price = decimal.Parse(request["T_base_price"].ToString());

                string pid = request["pid"];
                if (!string.IsNullOrEmpty(pid) && pid != "null")
                {
                    model.product_id = int.Parse(PageValidate.IsNumber(pid) ? pid : "-1");
                    DataSet ds = ccp.GetList(" product_id=" + int.Parse(pid));
                    DataRow dr = ds.Tables[0].Rows[0];
                    ccp.Update(model);

                    //日志
                    C_Sys_log log = new C_Sys_log();

                    int UserID = emp_id;
                    string UserName = empname;
                    string IPStreet = request.UserHostAddress;
                    string EventTitle = model.product_name;
                    string EventType = "产品修改";
                    int EventID = model.product_id;
                    if (dr["category_name"].ToString() != request["T_product_category"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品类别", dr["category_name"].ToString(), request["T_product_category"]);
                    }
                    if (dr["product_name"].ToString() != request["T_product_name"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品名字", dr["product_name"].ToString(), request["T_product_name"]);
                    }
                    if (dr["specifications"].ToString() != request["T_specifications"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品规格", dr["specifications"].ToString(), request["T_specifications"]);
                    }
                    if (dr["unit"].ToString() != request["T_product_unit"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "单位", dr["unit"].ToString(), request["T_product_unit"]);
                    }
                    if (dr["remarks"].ToString() != request["T_remarks"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]);
                    }
                    if (dr["price"].ToString() != request["T_price"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "价格", dr["price"].ToString(), request["T_price"]);
                    }
                    if (dr["base_price"].ToString() != request["T_base_price"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "底价", dr["base_price"].ToString(), request["T_base_price"]);
                    }
                }
                else
                {
                    model.isDelete = 0;
                    ccp.Add(model);
                }
            }

            if (request["Action"] == "grid")
            {
                int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                    sortname = " category_id";
                if (string.IsNullOrEmpty(sortorder))
                    sortorder = "desc";

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt = null;
                string serchtype = request["isdel"];
                if (serchtype == "1")
                {
                    serchtxt += " isDelete=1 ";
                }
                else
                {
                    serchtxt += " isDelete=0 ";
                }
                string categoryid = request["categoryid"];
                if (!string.IsNullOrEmpty(categoryid) && categoryid != "null")
                {
                    serchtxt += " and category_id=" + (PageValidate.IsNumber(categoryid) ? categoryid : "-1");
                }

                if (!string.IsNullOrEmpty(request["company"]))
                    serchtxt += " and product_name like N'%" + PageValidate.InputText( request["company"],255) + "%'";

                if (!string.IsNullOrEmpty(request["startdate_del"]))
                {
                    serchtxt += " and Delete_time >= '" + PageValidate.InputText( request["startdate_del"],255) + "'";
                }
                if (!string.IsNullOrEmpty(request["enddate_del"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate_del"]).AddHours(23).AddMinutes(59).AddSeconds(59);
                    serchtxt += " and Delete_time  <= '" + enddate + "'";
                }

                //权限
                DataSet ds = ccp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "gridmode")
            {
                int pid = int.Parse(request["pid"]);
                DataSet ds = ccp.GetModeList(" product_id=" + pid);

                /*
                //string dt = Common.DataToJson.DataToJSON(ds);
                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], "0");
                context.Response.Write(dt);
                */
                string modescript = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                        modescript += "{";
                        modescript += "id: '" + ds.Tables[0].Rows[i]["mode_name"].ToString() + "',";
                        modescript += "text: '" + ds.Tables[0].Rows[i]["mode_name"].ToString() + "'";
                        modescript += "},";

                }

                if (modescript != "")
                    modescript = modescript.Substring(0, modescript.Length - 1);

                modescript = "{Rows:[" + modescript;
                modescript += "]}";
                context.Response.Write(modescript);

            }
            if (request["Action"] == "form")
            {
                int pid = int.Parse(request["pid"]);
                DataSet ds = ccp.GetList(" product_id=" + pid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];
                DataSet ds = ccp.GetList(" product_id=" + int.Parse( c_id));

                BLL.CRM_order_details ccod = new BLL.CRM_order_details();
                if (ccod.GetList("product_id=" + c_id).Tables[0].Rows.Count > 0)
                {
                    //order
                    context.Response.Write("false:order");
                }
                else
                {
                    bool isdel = ccp.AdvanceDelete(int.Parse(c_id), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (isdel)
                    {
                        //日志
                        string EventType = "产品预删除";

                        int UserID = emp_id;
                        string UserName = empname;
                        string IPStreet = request.UserHostAddress;
                        int EventID = int.Parse(c_id);
                        string EventTitle = ds.Tables[0].Rows[0]["product_name"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;

                        C_Sys_log log = new C_Sys_log();

                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");

                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
            //regain
            if (request["Action"] == "regain")
            {
                string idlist = PageValidate.InputText( request["idlist"],100000);
                string[] arr = idlist.Split(',');

                DataSet ds = ccp.GetList("product_id in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    ccp.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if (true)
                {
                    //日志
                    string EventType = "恢复删除产品";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int UserID = emp_id;
                        string UserName = empname;
                        int EventID = idlist[i];
                        string IPStreet = request.UserHostAddress;
                        string EventTitle = ds.Tables[0].Rows[i]["product_name"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }

            }
            ////del
            if (request["Action"] == "del")
            {

                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "76");
                        if (delauth == "false")
                            canDel = false;
                        else
                            canDel = true;
                    }
                }
                if (canDel)
                {
                    string idlist = PageValidate.InputText( request["idlist"],100000);
                    string[] arr = idlist.Split(',');

                    string EventType = "彻底删除产品";

                    DataSet ds = ccp.GetList(" product_id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        ccp.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        //日志

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int UserID = emp_id;
                            string UserName = empname;
                            string IPStreet = request.UserHostAddress;
                            int EventID = idlist[i];
                            string EventTitle = ds.Tables[0].Rows[i]["product_name"].ToString();
                            string Original_txt = null;
                            string Current_txt = null;
                            C_Sys_log log = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }
            //serch
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_product   ccp   = new BLL.CRM_product();
            Model.CRM_product model = new Model.CRM_product();

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(request.Cookies["UserID"].Value);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "save")
            {
                model.category_id    = int.Parse(request["T_product_category_val"]);
                model.category_name  = PageValidate.InputText(request["T_product_category"], 255);
                model.product_name   = PageValidate.InputText(request["T_product_name"], 255);
                model.specifications = PageValidate.InputText(request["T_specifications"], 255);
                model.unit           = PageValidate.InputText(request["T_product_unit"], 255);
                model.remarks        = PageValidate.InputText(request["T_remarks"], 255);
                model.price          = decimal.Parse(request["T_price"].ToString());

                string pid = request["pid"];
                if (!string.IsNullOrEmpty(pid) && pid != "null")
                {
                    model.product_id = int.Parse(PageValidate.IsNumber(pid) ? pid : "-1");
                    DataSet ds = ccp.GetList(" product_id=" + int.Parse(pid));
                    DataRow dr = ds.Tables[0].Rows[0];
                    ccp.Update(model);

                    //日志
                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.product_name;
                    string EventType  = "产品修改";
                    int    EventID    = model.product_id;
                    if (dr["category_name"].ToString() != request["T_product_category"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品类别", dr["category_name"].ToString(), request["T_product_category"]);
                    }
                    if (dr["product_name"].ToString() != request["T_product_name"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品名字", dr["product_name"].ToString(), request["T_product_name"]);
                    }
                    if (dr["specifications"].ToString() != request["T_specifications"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品规格", dr["specifications"].ToString(), request["T_specifications"]);
                    }
                    if (dr["unit"].ToString() != request["T_product_unit"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "单位", dr["unit"].ToString(), request["T_product_unit"]);
                    }
                    if (dr["remarks"].ToString() != request["T_remarks"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]);
                    }
                    if (dr["price"].ToString() != request["T_price"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "价格", dr["price"].ToString(), request["T_price"]);
                    }
                }
                else
                {
                    ccp.Add(model);
                }
            }

            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " product_name";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = "desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt  = null;
                string serchtype = request["isdel"];
                if (serchtype == "1")
                {
                    serchtxt += " ISNULL(isDelete,0)=1 ";
                }
                else
                {
                    serchtxt += "ISNULL(isDelete,0)=0 ";
                }
                string categoryid = request["categoryid"];
                if (!string.IsNullOrEmpty(categoryid) && categoryid != "null")
                {
                    serchtxt += " and category_id=" + (PageValidate.IsNumber(categoryid) ? categoryid : "-1");
                }


                if (!string.IsNullOrEmpty(request["company"]))
                {
                    serchtxt += " and product_name like N'%" + PageValidate.InputText(request["company"], 255) + "%'";
                }

                if (!string.IsNullOrEmpty(request["startdate_del"]))
                {
                    serchtxt += " and Delete_time >= '" + PageValidate.InputText(request["startdate_del"], 255) + "'";
                }
                if (!string.IsNullOrEmpty(request["enddate_del"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate_del"]).AddHours(23).AddMinutes(59).AddSeconds(59);
                    serchtxt += " and Delete_time  <= '" + enddate + "'";
                }

                //权限
                DataSet ds = ccp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "form")
            {
                int     pid = int.Parse(request["pid"]);
                DataSet ds  = ccp.GetList(" product_id=" + pid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string  c_id = request["id"];
                DataSet ds   = ccp.GetList(" product_id=" + int.Parse(c_id));

                BLL.CRM_order_details ccod = new BLL.CRM_order_details();
                if (ccod.GetList("product_id=" + c_id).Tables[0].Rows.Count > 0)
                {
                    //order
                    context.Response.Write("false:order");
                }
                else
                {
                    bool isdel = ccp.AdvanceDelete(int.Parse(c_id), 1, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                    if (isdel)
                    {
                        //日志
                        string EventType = "产品预删除";


                        int    UserID       = emp_id;
                        string UserName     = empname;
                        string IPStreet     = request.UserHostAddress;
                        int    EventID      = int.Parse(c_id);
                        string EventTitle   = ds.Tables[0].Rows[0]["product_name"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();

                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
            //regain
            if (request["Action"] == "regain")
            {
                string   idlist = PageValidate.InputText(request["idlist"], 100000);
                string[] arr    = idlist.Split(',');

                DataSet ds = ccp.GetList("product_id in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    ccp.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                }

                if (true)
                {
                    //日志
                    string EventType = "恢复删除产品";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int    UserID       = emp_id;
                        string UserName     = empname;
                        int    EventID      = idlist[i];
                        string IPStreet     = request.UserHostAddress;
                        string EventTitle   = ds.Tables[0].Rows[i]["product_name"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            ////del
            if (request["Action"] == "del")
            {
                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "76");
                        if (delauth == "false")
                        {
                            canDel = false;
                        }
                        else
                        {
                            canDel = true;
                        }
                    }
                }
                if (canDel)
                {
                    string   idlist = PageValidate.InputText(request["idlist"], 100000);
                    string[] arr    = idlist.Split(',');

                    string EventType = "彻底删除产品";

                    DataSet ds = ccp.GetList(" product_id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        ccp.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        //日志

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int       UserID       = emp_id;
                            string    UserName     = empname;
                            string    IPStreet     = request.UserHostAddress;
                            int       EventID      = idlist[i];
                            string    EventTitle   = ds.Tables[0].Rows[i]["product_name"].ToString();
                            string    Original_txt = null;
                            string    Current_txt  = null;
                            C_Sys_log log          = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }
            //serch
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_product_category   ccpc  = new BLL.CRM_product_category();
            Model.CRM_product_category model = new Model.CRM_product_category();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "save")
            {
                string parentid = PageValidate.InputText(request["T_category_parent_val"], 50);
                model.parentid         = int.Parse(parentid);
                model.product_category = Common.PageValidate.InputText(request["T_category_name"], 250);
                model.product_icon     = Common.PageValidate.InputText(request["T_category_icon"], 250);

                string id  = PageValidate.InputText(request["id"], 50);
                string pid = PageValidate.InputText(request["T_category_parent_val"], 50);
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.id = int.Parse(id);

                    DataSet ds = ccpc.GetList(" id=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];

                    if (int.Parse(id) == int.Parse(pid))
                    {
                        context.Response.Write("false:type");
                    }
                    else
                    {
                        ccpc.Update(model);


                        //日志
                        C_Sys_log log = new C_Sys_log();

                        int    UserID     = emp_id;
                        string UserName   = empname;
                        string IPStreet   = request.UserHostAddress;
                        string EventTitle = model.product_category;
                        string EventType  = "产品类别修改";
                        int    EventID    = model.id;
                        if (dr["product_category"].ToString() != request["T_category_name"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品类别", dr["product_category"].ToString(), request["T_category_name"]);
                        }
                        if (dr["product_icon"].ToString() != request["T_category_icon"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "类别图标", dr["product_icon"].ToString(), request["T_category_icon"]);
                        }
                        if (dr["parentid"].ToString() != request["T_category_parent_val"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "上级类别", dr["parentid"].ToString(), request["T_category_parent_val"]);
                        }
                    }
                }

                else
                {
                    model.isDelete = 0;
                    ccpc.Add(model);
                }
            }

            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " id";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = " desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt = "1=1";
                if (!string.IsNullOrEmpty(request["company"]))
                {
                    serchtxt += " and product_category like N'%" + PageValidate.InputText(request["company"], 50) + "%'";
                }

                if (!string.IsNullOrEmpty(request["startdate_del"]))
                {
                    serchtxt += " and Delete_time >= '" + PageValidate.InputText(request["startdate_del"], 50) + "'";
                }
                if (!string.IsNullOrEmpty(request["enddate_del"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate_del"]);
                    serchtxt += " and Delete_time  <= '" + enddate.AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }
                //权限


                string dt = "";
                if (request["grid"] == "tree")
                {
                    DataSet ds = ccpc.GetList(0, serchtxt, sorttext);
                    dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}";
                }
                else
                {
                    DataSet ds = ccpc.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);
                    dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                }
                context.Response.Write(dt);
            }
            if (request["Action"] == "tree")
            {
                DataSet       ds  = ccpc.GetAllList();
                StringBuilder str = new StringBuilder();
                str.Append("[");
                str.Append(GetTreeString(0, ds.Tables[0]));
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "combo")
            {
                DataSet       ds  = ccpc.GetAllList();
                StringBuilder str = new StringBuilder();
                str.Append("[");
                str.Append("{id:0,text:'无',d_icon:''},");
                str.Append(GetTreeString(0, ds.Tables[0]));
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "form")
            {
                int     cid = int.Parse(request["id"]);
                DataSet ds  = ccpc.GetList("id=" + cid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }

            //del
            if (request["Action"] == "del")
            {
                //参数安全过滤
                string c_id = PageValidate.InputText(request["id"], 50);

                DataSet ds = ccpc.GetList(" id=" + int.Parse(c_id));

                BLL.CRM_product product = new BLL.CRM_product();
                if (product.GetList(" category_id=" + int.Parse(c_id)).Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false:product");
                }
                else if (ccpc.GetList("parentid=" + int.Parse(c_id)).Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false:parent");
                }
                else
                {
                    bool isdel = ccpc.Delete(int.Parse(c_id));
                    if (isdel)
                    {
                        //日志
                        string EventType = "产品类别删除";

                        int    UserID       = emp_id;
                        string UserName     = empname;
                        string IPStreet     = request.UserHostAddress;
                        int    EventID      = int.Parse(c_id);
                        string EventTitle   = ds.Tables[0].Rows[0]["product_category"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();

                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_product_category ccpc = new BLL.CRM_product_category();
            Model.CRM_product_category model = new Model.CRM_product_category();

            BLL.hr_employee emp = new BLL.hr_employee();
            int emp_id = int.Parse(request.Cookies["UserID"].Value);
            DataSet dsemp = emp.GetList("id=" + emp_id);
            string empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string uid = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "save")
            {
                string parentid = request["T_category_parent_val"];
                model.parentid = int.Parse(parentid);
                model.product_category = Common.PageValidate.InputText(request["T_category_name"], 250);
                model.product_icon = Common.PageValidate.InputText(request["T_category_icon"], 250);

                string id = request["id"];
                string pid = request["T_category_parent_val"];
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.id = int.Parse(id);

                    DataSet ds = ccpc.GetList(" id=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];

                    if (int.Parse(id) == int.Parse(pid))
                    {
                        context.Response.Write("false:type");
                    }
                    else
                    {
                        ccpc.Update(model);

                        //日志
                        C_Sys_log log = new C_Sys_log();

                        int UserID = emp_id;
                        string UserName = empname;
                        string IPStreet = request.UserHostAddress;
                        string EventTitle = model.product_category;
                        string EventType = "产品类别修改";
                        int EventID = model.id;
                        if (dr["product_category"].ToString() != request["T_category_name"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品类别", dr["product_category"].ToString(), request["T_category_name"]);
                        }
                        if (dr["product_icon"].ToString() != request["T_category_icon"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "类别图标", dr["product_icon"].ToString(), request["T_category_icon"]);
                        }
                        if (dr["parentid"].ToString() != request["T_category_parent_val"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "上级类别", dr["parentid"].ToString(), request["T_category_parent_val"]);
                        }
                    }
                }

                else
                {
                    model.isDelete = 0;
                    ccpc.Add(model);
                }
            }

            if (request["Action"] == "grid")
            {
                int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                    sortname = " id";
                if (string.IsNullOrEmpty(sortorder))
                    sortorder = " desc";

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt = null;
                string serchtype = request["isdel"];
                if (serchtype == "1")
                {
                    serchtxt += " isDelete=1 ";
                }
                else
                {
                    serchtxt += " isDelete=0 ";
                }
                if (!string.IsNullOrEmpty(request["company"]))
                    serchtxt += " and product_category like N'%" + request["company"] + "%'";

                if (!string.IsNullOrEmpty(request["startdate_del"]))
                {
                    serchtxt += " and Delete_time >= '" + request["startdate_del"] + "'";
                }
                if (!string.IsNullOrEmpty(request["enddate_del"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate_del"]);
                    serchtxt += " and Delete_time  <= '" + enddate.AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }
                //权限
                DataSet ds = ccpc.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = "";
                if (request["grid"] == "tree")
                    dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}";
                else
                    dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "tree")
            {
                DataSet ds = ccpc.GetList(" isDelete=0 ");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["product_category"] + "',d_icon:'../../" + ds.Tables[0].Rows[i]["product_icon"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "combo")
            {
                DataSet ds = ccpc.GetList(" isDelete=0");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                str.Append("{id:0,pid:0,text:'无',d_icon:''},");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["product_category"] + "',d_icon:'" + ds.Tables[0].Rows[i]["product_icon"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "form")
            {
                int cid = int.Parse(request["id"]);
                DataSet ds = ccpc.GetList("id=" + cid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }

            //del
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];

                DataSet ds = ccpc.GetList(" id=" + int.Parse(c_id));

                BLL.CRM_product product = new BLL.CRM_product();
                if (product.GetList(" category_id=" + int.Parse(c_id)).Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false:product");
                }
                else if(ccpc.GetList("parentid="+int.Parse(c_id)).Tables[0].Rows.Count>0){
                    context.Response.Write("false:parent");
                }
                else
                {
                    bool isdel = ccpc.AdvanceDelete(int.Parse(c_id), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (isdel)
                    {
                        //日志

                        string EventType = "产品类别预删除";

                        int UserID = emp_id;
                        string UserName = empname;
                        string IPStreet = request.UserHostAddress;
                        int EventID = int.Parse(c_id);
                        string EventTitle = ds.Tables[0].Rows[0]["product_category"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;

                        C_Sys_log log = new C_Sys_log();

                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }

            }
            //regain
            if (request["Action"] == "regain")
            {
                string idlist = PageValidate.InputText( request["idlist"],100000);
                string[] arr = idlist.Split(',');

                DataSet ds = ccpc.GetList("id in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    ccpc.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if (true)
                {
                    string EventType = "恢复删除产品类别";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int UserID = emp_id;
                        string UserName = empname;
                        int EventID = idlist[i];
                        string IPStreet = request.UserHostAddress;
                        string EventTitle = ds.Tables[0].Rows[i]["product_category"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }

            }
            ////del
            if (request["Action"] == "del")
            {

                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "74");
                        if (delauth == "false")
                            canDel = false;
                        else
                            canDel = true;
                    }
                }
                if (canDel)
                {
                    string idlist = PageValidate.InputText( request["idlist"],100000);
                    string[] arr = idlist.Split(',');

                    string EventType = "彻底删除产品类别";

                    DataSet ds = ccpc.GetList("id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        ccpc.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {

                            int UserID = emp_id;
                            string UserName = empname;
                            string IPStreet = request.UserHostAddress;
                            int EventID = idlist[i];
                            string EventTitle = ds.Tables[0].Rows[i]["product_category"].ToString();
                            string Original_txt = null;
                            string Current_txt = null;
                            C_Sys_log log = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }
        }
コード例 #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_product   ccp   = new BLL.CRM_product();
            Model.CRM_product model = new Model.CRM_product();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "save")
            {
                model.category_id    = int.Parse(request["T_product_category_val"]);
                model.category_name  = PageValidate.InputText(request["T_product_category"], 255);
                model.product_name   = PageValidate.InputText(request["T_product_name"], 255);
                model.specifications = PageValidate.InputText(request["T_specifications"], 255);
                model.unit           = PageValidate.InputText(request["T_product_unit"], 255);
                model.remarks        = PageValidate.InputText(request["T_remarks"], 255);
                model.price          = decimal.Parse(request["T_price"].ToString());

                string pid = PageValidate.InputText(request["pid"], 50);
                if (!string.IsNullOrEmpty(pid) && pid != "null")
                {
                    model.product_id = int.Parse(PageValidate.IsNumber(pid) ? pid : "-1");
                    DataSet ds = ccp.GetList(" product_id=" + int.Parse(pid));
                    DataRow dr = ds.Tables[0].Rows[0];
                    ccp.Update(model);

                    //日志
                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.product_name;
                    string EventType  = "产品修改";
                    int    EventID    = model.product_id;
                    if (dr["category_name"].ToString() != request["T_product_category"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品类别", dr["category_name"].ToString(), request["T_product_category"]);
                    }
                    if (dr["product_name"].ToString() != request["T_product_name"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品名字", dr["product_name"].ToString(), request["T_product_name"]);
                    }
                    if (dr["specifications"].ToString() != request["T_specifications"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品规格", dr["specifications"].ToString(), request["T_specifications"]);
                    }
                    if (dr["unit"].ToString() != request["T_product_unit"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "单位", dr["unit"].ToString(), request["T_product_unit"]);
                    }
                    if (dr["remarks"].ToString() != request["T_remarks"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]);
                    }
                    if (dr["price"].ToString() != request["T_price"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "价格", dr["price"].ToString(), request["T_price"]);
                    }
                }
                else
                {
                    model.isDelete = 0;
                    ccp.Add(model);
                }
            }

            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " category_id";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = "desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt = "1=1";
                if (!string.IsNullOrEmpty(request["categoryid"]))
                {
                    serchtxt += string.Format(" and category_id={0}", int.Parse(request["categoryid"]));
                }

                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    serchtxt += " and product_name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'";
                }

                //权限
                DataSet ds = ccp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "form")
            {
                int     pid = int.Parse(request["pid"]);
                DataSet ds  = ccp.GetList(" product_id=" + pid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                //参数安全过滤
                string  c_id = PageValidate.InputText(request["id"], 50);
                DataSet ds   = ccp.GetList(" product_id=" + int.Parse(c_id));

                BLL.CRM_order_details ccod = new BLL.CRM_order_details();
                if (ccod.GetList("product_id=" + int.Parse(c_id)).Tables[0].Rows.Count > 0)
                {
                    //order
                    context.Response.Write("false:order");
                }
                else
                {
                    bool isdel = ccp.Delete(int.Parse(c_id));
                    if (isdel)
                    {
                        //日志
                        string EventType = "产品删除";

                        int    UserID       = emp_id;
                        string UserName     = empname;
                        string IPStreet     = request.UserHostAddress;
                        int    EventID      = int.Parse(c_id);
                        string EventTitle   = ds.Tables[0].Rows[0]["product_name"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();

                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
        }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_product_category   ccpc  = new BLL.CRM_product_category();
            Model.CRM_product_category model = new Model.CRM_product_category();

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(request.Cookies["UserID"].Value);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "save")
            {
                string parentid = request["T_category_parent_val"];
                model.parentid         = int.Parse(parentid);
                model.product_category = Common.PageValidate.InputText(request["T_category_name"], 250);
                model.product_icon     = Common.PageValidate.InputText(request["T_category_icon"], 250);

                string id  = request["id"];
                string pid = request["T_category_parent_val"];
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.id = int.Parse(id);

                    DataSet ds = ccpc.GetList(" id=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];

                    if (int.Parse(id) == int.Parse(pid))
                    {
                        context.Response.Write("false:type");
                    }
                    else
                    {
                        ccpc.Update(model);


                        //日志
                        C_Sys_log log = new C_Sys_log();

                        int    UserID     = emp_id;
                        string UserName   = empname;
                        string IPStreet   = request.UserHostAddress;
                        string EventTitle = model.product_category;
                        string EventType  = "产品类别修改";
                        int    EventID    = model.id;
                        if (dr["product_category"].ToString() != request["T_category_name"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "产品类别", dr["product_category"].ToString(), request["T_category_name"]);
                        }
                        if (dr["product_icon"].ToString() != request["T_category_icon"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "类别图标", dr["product_icon"].ToString(), request["T_category_icon"]);
                        }
                        if (dr["parentid"].ToString() != request["T_category_parent_val"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "上级类别", dr["parentid"].ToString(), request["T_category_parent_val"]);
                        }
                    }
                }

                else
                {
                    ccpc.Add(model);
                }
            }

            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " parentid";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = "desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt  = null;
                string serchtype = request["isdel"];
                if (serchtype == "1")
                {
                    serchtxt += " ISNULL(isDelete,0)=1 ";
                }
                else
                {
                    serchtxt += "ISNULL(isDelete,0)=0 ";
                }
                if (!string.IsNullOrEmpty(request["company"]))
                {
                    serchtxt += " and product_category like N'%" + request["company"] + "%'";
                }

                if (!string.IsNullOrEmpty(request["startdate_del"]))
                {
                    serchtxt += " and Delete_time >= '" + request["startdate_del"] + "'";
                }
                if (!string.IsNullOrEmpty(request["enddate_del"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate_del"]);
                    serchtxt += " and Delete_time  <= '" + enddate.AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }
                //权限
                DataSet ds = ccpc.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = "";
                if (request["grid"] == "tree")
                {
                    dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}";
                }
                else
                {
                    dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                }
                context.Response.Write(dt);
            }
            if (request["Action"] == "tree")
            {
                DataSet       ds  = ccpc.GetList(" ISNULL(isDelete,0)=0 ");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["product_category"] + "',d_icon:'" + ds.Tables[0].Rows[i]["product_icon"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "combo")
            {
                DataSet       ds  = ccpc.GetList(" ISNULL(isDelete,0)=0");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                str.Append("{id:0,pid:0,text:'无',d_icon:''},");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["product_category"] + "',d_icon:'" + ds.Tables[0].Rows[i]["product_icon"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "form")
            {
                int     cid = int.Parse(request["id"]);
                DataSet ds  = ccpc.GetList("id=" + cid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }

            //del
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];

                DataSet ds = ccpc.GetList(" id=" + int.Parse(c_id));

                BLL.CRM_product product = new BLL.CRM_product();
                if (product.GetList(" category_id=" + int.Parse(c_id)).Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false:product");
                }
                else
                {
                    bool isdel = ccpc.AdvanceDelete(int.Parse(c_id), 1, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                    if (isdel)
                    {
                        //日志

                        string EventType = "产品类别预删除";

                        int    UserID       = emp_id;
                        string UserName     = empname;
                        string IPStreet     = request.UserHostAddress;
                        int    EventID      = int.Parse(c_id);
                        string EventTitle   = ds.Tables[0].Rows[0]["product_category"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();

                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
            //regain
            if (request["Action"] == "regain")
            {
                string   idlist = PageValidate.InputText(request["idlist"], 100000);
                string[] arr    = idlist.Split(',');

                DataSet ds = ccpc.GetList("id in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    ccpc.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                }

                if (true)
                {
                    string EventType = "恢复删除产品类别";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int    UserID       = emp_id;
                        string UserName     = empname;
                        int    EventID      = idlist[i];
                        string IPStreet     = request.UserHostAddress;
                        string EventTitle   = ds.Tables[0].Rows[i]["product_category"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            ////del
            if (request["Action"] == "del")
            {
                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "74");
                        if (delauth == "false")
                        {
                            canDel = false;
                        }
                        else
                        {
                            canDel = true;
                        }
                    }
                }
                if (canDel)
                {
                    string   idlist = PageValidate.InputText(request["idlist"], 100000);
                    string[] arr    = idlist.Split(',');

                    string EventType = "彻底删除产品类别";

                    DataSet ds = ccpc.GetList("id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        ccpc.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int       UserID       = emp_id;
                            string    UserName     = empname;
                            string    IPStreet     = request.UserHostAddress;
                            int       EventID      = idlist[i];
                            string    EventTitle   = ds.Tables[0].Rows[i]["product_category"].ToString();
                            string    Original_txt = null;
                            string    Current_txt  = null;
                            C_Sys_log log          = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }
        }