Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_receive cci = new BLL.CRM_receive();
            Model.CRM_receive model = new Model.CRM_receive();

            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")
            {
                DataRow dremp = dsemp.Tables[0].Rows[0];

                model.Receive_num = PageValidate.InputText(request["T_invoice_num"], 255);

                string orderid = request["orderid"];

                BLL.CRM_order order = new BLL.CRM_order();
                DataSet dsorder = order.GetList("id=" + int.Parse( orderid));

                model.order_id = int.Parse(orderid);
                if (dsorder.Tables[0].Rows.Count > 0)
                {
                    model.Customer_id = int.Parse(dsorder.Tables[0].Rows[0]["Customer_id"].ToString());
                    model.Customer_name = PageValidate.InputText(dsorder.Tables[0].Rows[0]["Customer_name"].ToString(), 255);
                }

                model.C_depid = int.Parse(request["T_department_val"].ToString());
                model.C_depname = PageValidate.InputText(request["T_department"].ToString(), 255);
                model.C_empid = int.Parse(request["T_employee_val"].ToString());
                model.C_empname = PageValidate.InputText(request["T_employee"].ToString(), 255);

                model.receive_real = decimal.Parse(request["T_invoice_amount"]);
                model.Receive_date = DateTime.Parse(request["T_invoice_date"].ToString());
                model.Pay_type_id = int.Parse(request["T_invoice_type_val"].ToString());
                model.Pay_type = PageValidate.InputText(request["T_invoice_type"].ToString(), 255);
                model.remarks = PageValidate.InputText(request["T_content"].ToString(), 12000);
                model.receive_direction_id = int.Parse(request["T_receive_direction_val"].ToString());
                model.receive_direction_name = PageValidate.InputText(request["T_receive_direction"], 255);
                model.Receive_amount = model.receive_direction_id * model.receive_real;

                string cid = request["receiveid"];
                if (!string.IsNullOrEmpty(cid) && cid != "null")
                {
                    model.id = int.Parse(PageValidate.IsNumber(cid) ? cid : "-1");

                    DataSet ds = cci.GetList(" id=" + model.id);
                    DataRow dr = ds.Tables[0].Rows[0];

                    model.create_id = int.Parse(ds.Tables[0].Rows[0]["create_id"].ToString());
                    model.create_name = ds.Tables[0].Rows[0]["create_name"].ToString();
                    model.create_date = DateTime.Parse(ds.Tables[0].Rows[0]["create_date"].ToString());

                    cci.Update(model);

                    C_Sys_log log = new C_Sys_log();

                    int UserID = emp_id;
                    string UserName = empname;
                    string IPStreet = request.UserHostAddress;
                    string EventTitle = model.Receive_num;
                    string EventType = "收款修改";
                    int EventID = model.id;

                    if (dr["Receive_amount"].ToString() != request["T_invoice_amount"].Replace(",", "").Replace(".00", ""))
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款金额", dr["Receive_amount"].ToString(), request["T_invoice_amount"].Replace(",", "").Replace(".00", ""));
                    }

                    if (dr["Pay_type"].ToString() != request["T_invoice_type"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "付款方式", dr["Pay_type"].ToString(), request["T_invoice_type"]);
                    }
                    if (dr["receive_direction_name"].ToString() != request["T_receive_direction"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款类别", dr["receive_direction_name"].ToString(), request["T_receive_direction"]);
                    }
                    if (dr["Receive_num"].ToString() != request["T_invoice_num"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "凭证号码", dr["Receive_num"].ToString(), request["T_invoice_num"]);
                    }
                    if (dr["Receive_date"].ToString() != request["T_invoice_date"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款时间", dr["Receive_date"].ToString(), request["T_invoice_date"]);
                    }

                    if (dr["remarks"].ToString() != request["T_content"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款内容", "原内容被修改", "原内容被修改");
                    }
                    if (dr["C_depname"].ToString() != request["T_department"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款人部门", dr["C_depname"].ToString(), request["T_department"]);
                    }
                    if (dr["C_empname"].ToString() != request["T_employee"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款人姓名", dr["C_empname"].ToString(), request["T_employee"]);
                    }
                }
                else
                {
                    model.isDelete = 0;
                    model.create_id = int.Parse(request.Cookies["UserID"].Value);
                    model.create_name = dremp["name"].ToString();
                    model.create_date = DateTime.Now;

                    cci.Add(model);
                }
                //更新订单收款金额
                order.UpdateReceive(orderid);
            }
            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 ";
                }
                string order_id = request["orderid"];
                if (!string.IsNullOrEmpty(order_id) && order_id != "null")
                    serchtxt += " and order_id=" + int.Parse(order_id);

                string customerid = request["customerid"];
                if (!string.IsNullOrEmpty(customerid) && customerid != "null")
                    serchtxt += " and Customer_id=" + int.Parse(customerid);

                if (!string.IsNullOrEmpty(request["company"]))
                    serchtxt += " and Customer_name like N'%" + request["company"] + "%'";

                if (!string.IsNullOrEmpty(request["receive_num"]))
                    serchtxt += " and Receive_num like N'%" + request["receive_num"] + "%'";

                if (!string.IsNullOrEmpty(request["pay_type"]))
                    serchtxt += " and Pay_type_id =" + request["pay_type_val"];

                if (!string.IsNullOrEmpty(request["department"]))
                    serchtxt += " and C_depid =" + request["department_val"];

                if (!string.IsNullOrEmpty(request["employee"]))
                    serchtxt += " and C_empid =" + request["employee_val"];

                if (!string.IsNullOrEmpty(request["startdate"]))
                    serchtxt += " and Receive_date >= '" + request["startdate"] + "'";

                if (!string.IsNullOrEmpty(request["enddate"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate"]);
                    serchtxt += " and Receive_date  <= '" + enddate + "'";
                }
                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"]).AddHours(23).AddMinutes(59).AddSeconds(59);
                    serchtxt += " and Delete_time  <= '" + enddate + "'";
                }
                //context.Response.Write(serchtxt);
                //权限
                DataSet ds = cci.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 invoiceid = int.Parse(request["receiveid"]);
                DataSet ds = cci.GetList("id=" + invoiceid);

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

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];
                if (!string.IsNullOrEmpty(c_id))
                {
                    if (!Common.PageValidate.IsNumber(c_id))
                    {
                        c_id = "-1";
                    }
                }
                else
                {
                    c_id = "-1";
                }

                DataSet ds = cci.GetList("id=" + c_id);

                bool isdel = cci.AdvanceDelete(int.Parse(c_id), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                //更新订单金额
                BLL.CRM_order order = new BLL.CRM_order();
                string orderid = ds.Tables[0].Rows[0]["order_id"].ToString();
                order.UpdateReceive(orderid);

                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]["Customer_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");
                }
            }
            if (request["Action"] == "regain")
            {
                string idlist = PageValidate.InputText( request["idlist"],100000);
                string[] arr = idlist.Split(',');

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

                BLL.CRM_order order = new BLL.CRM_order();
                for (int i = 0; i < arr.Length; i++)
                {
                    cci.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++)
                    {
                        //更新订单发票金额
                        string orderid = ds.Tables[0].Rows[0]["order_id"].ToString();
                        order.UpdateReceive(orderid);

                        int UserID = emp_id;
                        string UserName = empname;
                        int EventID = idlist[i];
                        string IPStreet = request.UserHostAddress;
                        string EventTitle = ds.Tables[0].Rows[i]["Customer_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, "70");
                        if (delauth == "false")
                            canDel = false;
                        else
                            canDel = true;
                    }
                }
                if (canDel)
                {
                    string idlist = PageValidate.InputText( request["idlist"],100000);
                    string[] arr = idlist.Split(',');

                    DataSet ds = cci.GetList("id in (" + idlist.Trim() + ")");
                    string EventType = "彻底删除收款";

                    BLL.CRM_order order = new BLL.CRM_order();
                    for (int i = 0; i < arr.Length; i++)
                    {
                        cci.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]["Customer_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");
                }
            }
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_receive   cci   = new BLL.CRM_receive();
            Model.CRM_receive model = new Model.CRM_receive();

            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")
            {
                DataRow dremp = dsemp.Tables[0].Rows[0];

                model.Receive_num = PageValidate.InputText(request["T_invoice_num"], 255);

                string orderid = request["orderid"];

                BLL.CRM_order order   = new BLL.CRM_order();
                DataSet       dsorder = order.GetList("id=" + int.Parse(orderid));

                model.order_id = int.Parse(orderid);
                if (dsorder.Tables[0].Rows.Count > 0)
                {
                    model.Customer_id   = int.Parse(dsorder.Tables[0].Rows[0]["Customer_id"].ToString());
                    model.Customer_name = PageValidate.InputText(dsorder.Tables[0].Rows[0]["Customer_name"].ToString(), 255);
                }

                model.C_depid   = int.Parse(request["T_department_val"].ToString());
                model.C_depname = PageValidate.InputText(request["T_department"].ToString(), 255);
                model.C_empid   = int.Parse(request["T_employee_val"].ToString());
                model.C_empname = PageValidate.InputText(request["T_employee"].ToString(), 255);

                model.receive_real           = decimal.Parse(request["T_invoice_amount"]);
                model.Receive_date           = DateTime.Parse(request["T_invoice_date"].ToString());
                model.Pay_type_id            = int.Parse(request["T_invoice_type_val"].ToString());
                model.Pay_type               = PageValidate.InputText(request["T_invoice_type"].ToString(), 255);
                model.remarks                = PageValidate.InputText(request["T_content"].ToString(), 12000);
                model.receive_direction_id   = int.Parse(request["T_receive_direction_val"].ToString());
                model.receive_direction_name = PageValidate.InputText(request["T_receive_direction"], 255);
                model.Receive_amount         = model.receive_direction_id * model.receive_real;

                string cid = request["receiveid"];
                if (!string.IsNullOrEmpty(cid) && cid != "null")
                {
                    model.id = int.Parse(PageValidate.IsNumber(cid) ? cid : "-1");

                    DataSet ds = cci.GetList(" id=" + model.id);
                    DataRow dr = ds.Tables[0].Rows[0];

                    model.create_id   = int.Parse(ds.Tables[0].Rows[0]["create_id"].ToString());
                    model.create_name = ds.Tables[0].Rows[0]["create_name"].ToString();
                    model.create_date = DateTime.Parse(ds.Tables[0].Rows[0]["create_date"].ToString());

                    cci.Update(model);

                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.Receive_num;
                    string EventType  = "收款修改";
                    int    EventID    = model.id;

                    if (dr["Receive_amount"].ToString() != request["T_invoice_amount"].Replace(",", "").Replace(".00", ""))
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款金额", dr["Receive_amount"].ToString(), request["T_invoice_amount"].Replace(",", "").Replace(".00", ""));
                    }

                    if (dr["Pay_type"].ToString() != request["T_invoice_type"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "付款方式", dr["Pay_type"].ToString(), request["T_invoice_type"]);
                    }
                    if (dr["receive_direction_name"].ToString() != request["T_receive_direction"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款类别", dr["receive_direction_name"].ToString(), request["T_receive_direction"]);
                    }
                    if (dr["Receive_num"].ToString() != request["T_invoice_num"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "凭证号码", dr["Receive_num"].ToString(), request["T_invoice_num"]);
                    }
                    if (dr["Receive_date"].ToString() != request["T_invoice_date"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款时间", dr["Receive_date"].ToString(), request["T_invoice_date"]);
                    }

                    if (dr["remarks"].ToString() != request["T_content"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款内容", "原内容被修改", "原内容被修改");
                    }
                    if (dr["C_depname"].ToString() != request["T_department"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款人部门", dr["C_depname"].ToString(), request["T_department"]);
                    }
                    if (dr["C_empname"].ToString() != request["T_employee"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款人姓名", dr["C_empname"].ToString(), request["T_employee"]);
                    }
                }
                else
                {
                    model.create_id   = int.Parse(request.Cookies["UserID"].Value);
                    model.create_name = dremp["name"].ToString();
                    model.create_date = DateTime.Now;

                    cci.Add(model);
                }
                //更新订单收款金额
                order.UpdateReceive(orderid);
            }
            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 = " Receive_date";
                }
                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 order_id = request["orderid"];

                if (!string.IsNullOrEmpty(order_id) && order_id != "null")
                {
                    serchtxt += " and order_id=" + int.Parse(order_id);
                }

                if (!string.IsNullOrEmpty(request["company"]))
                {
                    serchtxt += " and Customer_name like N'%" + request["company"] + "%'";
                }

                if (!string.IsNullOrEmpty(request["receive_num"]))
                {
                    serchtxt += " and Receive_num like N'%" + request["receive_num"] + "%'";
                }

                if (!string.IsNullOrEmpty(request["pay_type"]))
                {
                    serchtxt += " and Pay_type_id =" + request["pay_type_val"];
                }

                if (!string.IsNullOrEmpty(request["department"]))
                {
                    serchtxt += " and C_depid =" + request["department_val"];
                }

                if (!string.IsNullOrEmpty(request["employee"]))
                {
                    serchtxt += " and C_empid =" + request["employee_val"];
                }

                if (!string.IsNullOrEmpty(request["startdate"]))
                {
                    serchtxt += " and Receive_date >= '" + request["startdate"] + "'";
                }

                if (!string.IsNullOrEmpty(request["enddate"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate"]);
                    serchtxt += " and Receive_date  <= '" + enddate + "'";
                }
                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"]).AddHours(23).AddMinutes(59).AddSeconds(59);
                    serchtxt += " and Delete_time  <= '" + enddate + "'";
                }


                //权限
                DataSet ds = cci.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     invoiceid = int.Parse(request["receiveid"]);
                DataSet ds        = cci.GetList("id=" + invoiceid);

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

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];
                if (!string.IsNullOrEmpty(c_id))
                {
                    if (!Common.PageValidate.IsNumber(c_id))
                    {
                        c_id = "-1";
                    }
                }
                else
                {
                    c_id = "-1";
                }

                DataSet ds = cci.GetList("id=" + c_id);

                bool isdel = cci.AdvanceDelete(int.Parse(c_id), 1, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));

                //更新订单金额
                BLL.CRM_order order   = new BLL.CRM_order();
                string        orderid = ds.Tables[0].Rows[0]["order_id"].ToString();
                order.UpdateReceive(orderid);

                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]["Customer_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");
                }
            }
            if (request["Action"] == "regain")
            {
                string   idlist = PageValidate.InputText(request["idlist"], 100000);
                string[] arr    = idlist.Split(',');

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


                BLL.CRM_order order = new BLL.CRM_order();
                for (int i = 0; i < arr.Length; i++)
                {
                    cci.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++)
                    {
                        //更新订单发票金额
                        string orderid = ds.Tables[0].Rows[0]["order_id"].ToString();
                        order.UpdateReceive(orderid);

                        int    UserID       = emp_id;
                        string UserName     = empname;
                        int    EventID      = idlist[i];
                        string IPStreet     = request.UserHostAddress;
                        string EventTitle   = ds.Tables[0].Rows[i]["Customer_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, "70");
                        if (delauth == "false")
                        {
                            canDel = false;
                        }
                        else
                        {
                            canDel = true;
                        }
                    }
                }
                if (canDel)
                {
                    string   idlist = PageValidate.InputText(request["idlist"], 100000);
                    string[] arr    = idlist.Split(',');

                    DataSet ds        = cci.GetList("id in (" + idlist.Trim() + ")");
                    string  EventType = "彻底删除收款";


                    BLL.CRM_order order = new BLL.CRM_order();
                    for (int i = 0; i < arr.Length; i++)
                    {
                        cci.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]["Customer_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");
                }
            }
        }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Param_SysParam   psp   = new BLL.Param_SysParam();
            Model.Param_SysParam model = new Model.Param_SysParam();

            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"] == "GetApp")
            {
                BLL.Param_SysParam_Type cpst = new BLL.Param_SysParam_Type();
                DataSet ds = cpst.GetList(0, "", "params_order");

                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:0,text:'" + ds.Tables[0].Rows[i]["params_name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "GetParams")
            {
                string parentid = PageValidate.InputText(request["parentid"], 50);

                DataSet ds = psp.GetList(0, " parentid=" + int.Parse(parentid), "params_order");
                string  dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                context.Response.Write(dt);
            }

            //combo
            if (request["Action"] == "combo")
            {
                string parentid = PageValidate.InputText(request["parentid"], 50);

                DataSet ds = psp.GetList(0, " parentid=" + int.Parse(parentid), "params_order");

                StringBuilder str = new StringBuilder();

                str.Append("[");
                //str.Append("{id:0,text:'无'},");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["params_name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                DataSet ds = psp.GetList("id=" + int.Parse(request["paramid"]));

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

                context.Response.Write(dt);
            }
            //save
            if (request["Action"] == "save")
            {
                model.params_name  = PageValidate.InputText(request["T_param_name"], 255);
                model.params_order = int.Parse(request["T_param_order"]);

                string id = request["paramid"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = psp.GetList("id=" + int.Parse(id));
                    model.parentid = int.Parse(ds.Tables[0].Rows[0]["parentid"].ToString());
                    model.id       = int.Parse(id);
                    psp.Update(model);
                }
                else
                {
                    model.parentid = int.Parse(request["parentid"]);
                    psp.Add(model);
                }
            }
            //del
            if (request["Action"] == "del")
            {
                string parentid = request["parentid"];
                string paramid  = request["paramid"];

                BLL.CRM_Customer customer = new BLL.CRM_Customer();
                BLL.CRM_Follow   follow   = new BLL.CRM_Follow();
                BLL.CRM_order    order    = new BLL.CRM_order();
                BLL.CRM_invoice  invoice  = new BLL.CRM_invoice();
                BLL.CRM_receive  receive  = new BLL.CRM_receive();

                DataSet ds = null;

                switch (int.Parse(parentid))
                {
                case 8: ds = customer.GetList("industry_id=" + int.Parse(paramid)); break;

                case 1: ds = customer.GetList("CustomerType_id=" + int.Parse(paramid)); break;

                case 2: ds = customer.GetList("CustomerLevel_id=" + int.Parse(paramid)); break;

                case 3: ds = customer.GetList("CustomerSource_id=" + int.Parse(paramid)); break;

                case 4: ds = follow.GetList("Follow_Type_id=" + int.Parse(paramid)); break;

                case 5: ds = order.GetList("pay_type_id=" + int.Parse(paramid)); if (ds.Tables[0].Rows.Count == 0)
                    {
                        ds = receive.GetList("Pay_type_id=" + int.Parse(paramid));
                    }
                    break;

                case 6: ds = order.GetList("Order_status_id=" + int.Parse(paramid)); break;

                case 7: ds = invoice.GetList("invoice_type_id=" + int.Parse(paramid)); break;
                }

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false:data");
                    return;
                }

                bool isdel = psp.Delete(int.Parse(paramid));
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            if (request["Action"] == "validate")
            {
                string param_name = PageValidate.InputText(request["T_param_name"], 50);
                string parentid   = PageValidate.InputText(request["parentid"], 50);
                string cid        = PageValidate.InputText(request["T_cid"], 50);
                if (string.IsNullOrEmpty(cid) || cid == "null")
                {
                    cid = "0";
                }

                DataSet ds = psp.GetList(string.Format(" params_name='{0}' and parentid={1} and id!={2} ", param_name, parentid, cid));
                //context.Response.Write(" Count:" + ds.Tables[0].Rows.Count);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false");
                }
                else
                {
                    context.Response.Write("true");
                }
            }
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;


            BLL.CRM_order   order = new BLL.CRM_order();
            Model.CRM_order model = new Model.CRM_order();

            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")
            {
                DataRow dremp = dsemp.Tables[0].Rows[0];

                model.Customer_id   = int.Parse(request["T_Customer_val"]);
                model.Customer_name = PageValidate.InputText(request["T_Customer"], 255);

                model.Order_date      = DateTime.Parse(request["T_date"]);
                model.pay_type_id     = int.Parse(request["T_paytype_val"]);
                model.pay_type        = PageValidate.InputText(request["T_paytype"], 255);
                model.Order_details   = PageValidate.InputText(request["T_details"].ToString(), 4000);
                model.Order_status_id = int.Parse(request["T_status_val"]);
                model.Order_status    = PageValidate.InputText(request["T_status"], 255);
                model.Order_amount    = decimal.Parse(request["T_amount"]);

                model.create_id   = int.Parse(dremp["ID"].ToString());
                model.create_date = DateTime.Now;

                model.C_dep_id   = int.Parse(request["T_department_val"]);
                model.C_dep_name = PageValidate.InputText(request["T_department"], 255);
                model.C_emp_id   = int.Parse(request["T_employee_val"]);
                model.C_emp_name = PageValidate.InputText(request["T_employee"], 255);

                model.F_dep_id   = int.Parse(request["T_department1_val"]);
                model.F_dep_name = PageValidate.InputText(request["T_department1"], 255);
                model.F_emp_id   = int.Parse(request["T_employee1_val"]);
                model.F_emp_name = PageValidate.InputText(request["T_employee1"], 255);

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


                    order.Update(model);
                    //context.Response.Write(model.id );
                    context.Response.Write("{success:success}");

                    C_Sys_log log        = new C_Sys_log();
                    int       UserID     = emp_id;
                    string    UserName   = empname;
                    string    IPStreet   = request.UserHostAddress;
                    string    EventTitle = model.Customer_name;
                    string    EventType  = "订单修改";
                    int       EventID    = model.id;

                    if (dr["Customer_name"].ToString() != request["T_Customer"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户", dr["Customer_name"].ToString(), request["T_Customer"]);
                    }
                    if (dr["Order_details"].ToString() != request["T_details"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "订单详情", "原内容被修改", "原内容被修改");
                    }
                    if (dr["Order_date"].ToString() != request["T_date"].ToString() + " 0:00:00")
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "成交时间", dr["Order_date"].ToString(), request["T_date"].ToString() + " 0:00:00");
                    }
                    if (dr["Order_amount"].ToString() != request["T_amount"].Replace(",", "").Replace(".00", ""))
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "订单总额", dr["Order_amount"].ToString(), request["T_amount"].Replace(",", "").Replace(".00", ""));
                    }
                    if (dr["Order_status"].ToString() != request["T_status"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "订单状态", dr["Order_status"].ToString(), request["T_status"]);
                    }
                    if (dr["F_dep_name"].ToString() != request["T_department1"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "促成人员部门", dr["F_dep_name"].ToString(), request["T_department1"]);
                    }
                    if (dr["F_emp_name"].ToString() != request["T_employee1"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "促成人员", dr["F_emp_name"].ToString(), request["T_employee1"]);
                    }
                    if (dr["pay_type"].ToString() != request["T_paytype"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "支付方式", dr["pay_type"].ToString(), request["T_paytype"]);
                    }
                }
                else
                {
                    model.Serialnumber = DateTime.Now.AddMilliseconds(3).ToString("yyyyMMddHHmmssfff").Trim();
                    //model.arrears_invoice = decimal.Parse(request["T_amount"]);
                    orderid = order.Add(model);
                    context.Response.Write("{success:success}");
                }
                //更新订单收款金额
                order.UpdateReceive(orderid.ToString());
                //更新订单发票金额
                order.UpdateInvoice(orderid.ToString());

                string json             = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize <PostData[]>(json);

                BLL.CRM_order_details   cod      = new BLL.CRM_order_details();
                Model.CRM_order_details modeldel = new Model.CRM_order_details();

                modeldel.order_id = orderid;
                cod.Delete(" order_id=" + modeldel.order_id);
                for (int i = 0; i < postdata.Length; i++)
                {
                    modeldel.product_id   = postdata[i].Product_id;
                    modeldel.product_name = postdata[i].Product_name;
                    modeldel.quantity     = postdata[i].Quantity;
                    modeldel.unit         = postdata[i].Unit;
                    modeldel.price        = postdata[i].Price;
                    modeldel.amount       = postdata[i].Amount;

                    cod.Add(modeldel);
                }
            }

            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 = " Create_date";
                }
                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 issar = request["issarr"];
                if (issar == "1")
                {
                    serchtxt += " and isnull( arrears_money,0)>0";
                }


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

                if (!string.IsNullOrEmpty(request["contact"]))
                {
                    serchtxt += " and Order_status_id = " + int.Parse(request["contact_val"]);
                }

                if (!string.IsNullOrEmpty(request["department"]))
                {
                    serchtxt += " and F_dep_id = " + int.Parse(request["department_val"]);
                }

                if (!string.IsNullOrEmpty(request["employee"]))
                {
                    serchtxt += " and F_emp_id = " + int.Parse(request["employee_val"]);
                }

                if (!string.IsNullOrEmpty(request["startdate"]))
                {
                    serchtxt += " and Order_date >= '" + PageValidate.InputText(request["startdate"], 255) + "'";
                }

                if (!string.IsNullOrEmpty(request["enddate"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate"]);
                    serchtxt += " and Order_date <= '" + DateTime.Parse(request["enddate"]).AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }

                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 = order.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                DataSet dsauth = DataAuth(ds, request.Cookies["UserID"].Value);

                string dt = Common.GetGridJSON.DataTableToJSON1(dsauth.Tables[0], Total);
                context.Response.Write(dt);
            }

            if (request["Action"] == "gridbycustomerid")
            {
                string customerid = request["customerid"];

                DataSet ds = order.GetList(0, " ISNULL(isDelete,0)=0 and Customer_id =" + int.Parse(customerid), " Order_date desc");
                context.Response.Write(Common.GetGridJSON.DataTableToJSON(ds.Tables[0]));
            }
            if (request["Action"] == "form")
            {
                int     pid = int.Parse(request["orderid"]);
                DataSet ds  = order.GetList("id=" + pid);

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

                context.Response.Write(dt);
            }
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];

                DataSet ds = order.GetList("id=" + c_id);

                BLL.CRM_contract contract = new BLL.CRM_contract();
                BLL.CRM_invoice  invoice  = new BLL.CRM_invoice();
                BLL.CRM_receive  receive  = new BLL.CRM_receive();
                if (invoice.GetList("order_id=" + c_id).Tables[0].Rows.Count > 0)
                {
                    //invoice
                    context.Response.Write("false:invoice");
                }
                else if (receive.GetList("order_id=" + c_id).Tables[0].Rows.Count > 0)
                {
                    //receive
                    context.Response.Write("false:receive");
                }
                else
                {
                    bool canedel = true;
                    if (uid != "admin")
                    {
                        Data.GetDataAuth dataauth = new Data.GetDataAuth();
                        string           txt      = dataauth.GetDataAuthByid("3", "Sys_del", emp_id.ToString());

                        string[] arr = txt.Split(':');
                        switch (arr[0])
                        {
                        case "none":
                            canedel = false;
                            break;

                        case "my":
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                if (ds.Tables[0].Rows[i]["C_emp_id"].ToString() == arr[1])
                                {
                                    canedel = true;
                                }
                                else
                                {
                                    canedel = false;
                                }
                            }
                            break;

                        case "dep":
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                if (ds.Tables[0].Rows[i]["C_dep_id"].ToString() == arr[1])
                                {
                                    canedel = true;
                                }
                                else
                                {
                                    canedel = false;
                                }
                            }
                            break;

                        case "all":
                            canedel = true;
                            break;
                        }
                    }
                    if (canedel)
                    {
                        bool isdel = order.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]["Customer_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("delfalse");
                    }
                }
            }

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

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

                for (int i = 0; i < arr.Length; i++)
                {
                    order.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]["Customer_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");
                }
            }

            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, "66");
                        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 = order.GetList("id in (" + idlist.Trim() + ")");

                    bool cando = true;


                    for (int i = 0; i < arr.Length; i++)
                    {
                        bool deleted = order.Delete(int.Parse(arr[i]));

                        if (!deleted)
                        {
                            cando = false;
                        }
                    }

                    if (cando)
                    {
                        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]["Customer_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");
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_receive   cci   = new BLL.CRM_receive();
            Model.CRM_receive model = new Model.CRM_receive();

            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")
            {
                DataRow dremp = dsemp.Tables[0].Rows[0];

                model.Receive_num = PageValidate.InputText(request["T_invoice_num"], 255);

                string orderid = PageValidate.InputText(request["orderid"], 50);

                BLL.CRM_order order   = new BLL.CRM_order();
                DataSet       dsorder = order.GetList("id=" + int.Parse(orderid));

                model.order_id = int.Parse(orderid);
                if (dsorder.Tables[0].Rows.Count > 0)
                {
                    model.Customer_id   = int.Parse(dsorder.Tables[0].Rows[0]["Customer_id"].ToString());
                    model.Customer_name = PageValidate.InputText(dsorder.Tables[0].Rows[0]["Customer_name"].ToString(), 255);
                }

                model.C_depid   = int.Parse(request["T_dep_val"].ToString());
                model.C_depname = PageValidate.InputText(request["T_dep"].ToString(), 255);
                model.C_empid   = int.Parse(request["T_employee_val"].ToString());
                model.C_empname = PageValidate.InputText(request["T_employee1"].ToString(), 255);

                model.receive_real           = decimal.Parse(request["T_invoice_amount"]);
                model.Receive_date           = DateTime.Parse(request["T_invoice_date"].ToString());
                model.Pay_type_id            = int.Parse(request["T_invoice_type_val"].ToString());
                model.Pay_type               = PageValidate.InputText(request["T_invoice_type"].ToString(), 255);
                model.remarks                = PageValidate.InputText(request["T_content"].ToString(), 12000);
                model.receive_direction_id   = int.Parse(request["T_receive_direction_val"].ToString());
                model.receive_direction_name = PageValidate.InputText(request["T_receive_direction"], 255);
                model.Receive_amount         = model.receive_direction_id * model.receive_real;

                string cid = PageValidate.InputText(request["receiveid"], 50);
                if (!string.IsNullOrEmpty(cid) && cid != "null")
                {
                    model.id = int.Parse(PageValidate.IsNumber(cid) ? cid : "-1");

                    DataSet ds = cci.GetList(" id=" + model.id);
                    DataRow dr = ds.Tables[0].Rows[0];

                    cci.Update(model);

                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.Receive_num;
                    string EventType  = "收款修改";
                    int    EventID    = model.id;

                    if (dr["Receive_amount"].ToString() != request["T_invoice_amount"].Replace(",", "").Replace(".00", ""))
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款金额", dr["Receive_amount"].ToString(), request["T_invoice_amount"].Replace(",", "").Replace(".00", ""));
                    }

                    if (dr["Pay_type"].ToString() != request["T_invoice_type"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "付款方式", dr["Pay_type"].ToString(), request["T_invoice_type"]);
                    }

                    if (dr["receive_direction_name"].ToString() != request["T_receive_direction"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款类别", dr["receive_direction_name"].ToString(), request["T_receive_direction"]);
                    }

                    if (dr["Receive_num"].ToString() != request["T_invoice_num"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "凭证号码", dr["Receive_num"].ToString(), request["T_invoice_num"]);
                    }

                    if (dr["Receive_date"].ToString() != request["T_invoice_date"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款时间", dr["Receive_date"].ToString(), request["T_invoice_date"]);
                    }

                    if (dr["remarks"].ToString() != request["T_content"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款内容", "原内容被修改", "原内容被修改");
                    }

                    if (dr["C_depname"].ToString() != request["T_dep"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款人部门", dr["C_depname"].ToString(), request["T_dep"]);
                    }

                    if (dr["C_empname"].ToString() != request["T_employee1"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "收款人姓名", dr["C_empname"].ToString(), request["T_employee1"]);
                    }
                }
                else
                {
                    model.isDelete    = 0;
                    model.create_id   = emp_id;
                    model.create_name = dremp["name"].ToString();
                    model.create_date = DateTime.Now;

                    cci.Add(model);
                }
                //更新订单收款金额
                order.UpdateReceive(orderid);
            }
            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";
                string order_id = request["orderid"];
                if (!string.IsNullOrEmpty(order_id) && order_id != "null")
                {
                    serchtxt += " and order_id=" + int.Parse(order_id);
                }

                string customerid = request["customerid"];
                if (!string.IsNullOrEmpty(customerid) && customerid != "null")
                {
                    serchtxt += " and Customer_id=" + int.Parse(customerid);
                }

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

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

                if (!string.IsNullOrEmpty(request["pay_type"]))
                {
                    serchtxt += " and Pay_type_id =" + int.Parse(request["pay_type_val"]);
                }

                if (!string.IsNullOrEmpty(request["department"]))
                {
                    serchtxt += " and C_depid =" + int.Parse(request["department_val"]);
                }

                if (!string.IsNullOrEmpty(request["employee"]))
                {
                    serchtxt += " and C_empid =" + int.Parse(request["employee_val"]);
                }

                if (!string.IsNullOrEmpty(request["startdate"]))
                {
                    serchtxt += " and Receive_date >= '" + PageValidate.InputText(request["startdate"], 50) + "'";
                }

                if (!string.IsNullOrEmpty(request["enddate"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate"]);
                    serchtxt += " and Receive_date  <= '" + enddate + "'";
                }
                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"]).AddHours(23).AddMinutes(59).AddSeconds(59);
                    serchtxt += " and Delete_time  <= '" + enddate + "'";
                }


                //权限
                DataSet ds = cci.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     invoiceid = int.Parse(request["receiveid"]);
                DataSet ds        = cci.GetList("id=" + invoiceid);

                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   = cci.GetList("id=" + int.Parse(c_id));

                bool isdel = cci.Delete(int.Parse(c_id));

                //更新订单金额
                BLL.CRM_order order   = new BLL.CRM_order();
                string        orderid = ds.Tables[0].Rows[0]["order_id"].ToString();
                order.UpdateReceive(orderid);

                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]["Customer_name"].ToString();
                    string Original_txt = ds.Tables[0].Rows[0]["Receive_amount"].ToString();
                    string Current_txt  = null;

                    C_Sys_log log = new C_Sys_log();

                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "金额", Original_txt, Current_txt);

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.CRM_order order = new BLL.CRM_order();
            Model.CRM_order model = new Model.CRM_order();

            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")
            {
                DataRow dremp = dsemp.Tables[0].Rows[0];

                model.Customer_id = int.Parse(request["T_Customer_val"]);
                model.Customer_name = PageValidate.InputText(request["T_Customer"], 255);

                model.Order_date = DateTime.Parse(request["T_date"]);
                model.pay_type_id = int.Parse(request["T_paytype_val"]);
                model.pay_type = PageValidate.InputText(request["T_paytype"], 255);
                model.Order_details = PageValidate.InputText(request["T_details"].ToString(), 4000);
                model.Order_status_id = int.Parse(request["T_status_val"]);
                model.Order_status = PageValidate.InputText(request["T_status"], 255);
                model.Order_amount = decimal.Parse(request["T_amount"]);

                model.create_id = int.Parse(dremp["ID"].ToString());
                model.create_date = DateTime.Now;

                model.C_dep_id = int.Parse(request["T_department_val"]);
                model.C_dep_name = PageValidate.InputText(request["T_department"], 255);
                model.C_emp_id = int.Parse(request["T_employee_val"]);
                model.C_emp_name = PageValidate.InputText(request["T_employee"], 255);

                model.F_dep_id = int.Parse(request["T_department1_val"]);
                model.F_dep_name = PageValidate.InputText(request["T_department1"], 255);
                model.F_emp_id = int.Parse(request["T_employee1_val"]);
                model.F_emp_name = PageValidate.InputText(request["T_employee1"], 255);

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

                    order.Update(model);
                    //context.Response.Write(model.id );
                    context.Response.Write("{success:success}");

                    C_Sys_log log = new C_Sys_log();
                    int UserID = emp_id;
                    string UserName = empname;
                    string IPStreet = request.UserHostAddress;
                    string EventTitle = model.Customer_name;
                    string EventType = "订单修改";
                    int EventID = model.id;

                    if (dr["Customer_name"].ToString() != request["T_Customer"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "客户", dr["Customer_name"].ToString(), request["T_Customer"]);
                    }
                    if (dr["Order_details"].ToString() != request["T_details"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "订单详情", "原内容被修改", "原内容被修改");
                    }
                    if (dr["Order_date"].ToString() != request["T_date"].ToString() + " 0:00:00")
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "成交时间", dr["Order_date"].ToString(), request["T_date"].ToString() + " 0:00:00");
                    }
                    if (dr["Order_amount"].ToString() != request["T_amount"].Replace(",", "").Replace(".00", ""))
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "订单总额", dr["Order_amount"].ToString(), request["T_amount"].Replace(",", "").Replace(".00", ""));
                    }
                    if (dr["Order_status"].ToString() != request["T_status"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "订单状态", dr["Order_status"].ToString(), request["T_status"]);
                    }
                    if (dr["F_dep_name"].ToString() != request["T_department1"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "促成人员部门", dr["F_dep_name"].ToString(), request["T_department1"]);
                    }
                    if (dr["F_emp_name"].ToString() != request["T_employee1"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "促成人员", dr["F_emp_name"].ToString(), request["T_employee1"]);
                    }
                    if (dr["pay_type"].ToString() != request["T_paytype"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "支付方式", dr["pay_type"].ToString(), request["T_paytype"]);
                    }
                }
                else
                {
                    model.isDelete = 0;
                    model.Serialnumber = DateTime.Now.AddMilliseconds(3).ToString("yyyyMMddHHmmssfff").Trim();
                    //model.arrears_invoice = decimal.Parse(request["T_amount"]);
                    orderid = order.Add(model);
                    context.Response.Write("{success:success}");
                }
                //更新订单收款金额
                order.UpdateReceive(orderid.ToString());
                //更新订单发票金额
                order.UpdateInvoice(orderid.ToString());

                string json = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize<PostData[]>(json);

                BLL.CRM_order_details cod = new BLL.CRM_order_details();
                Model.CRM_order_details modeldel = new Model.CRM_order_details();

                modeldel.order_id = orderid;
                cod.Delete(" order_id=" + modeldel.order_id);
                for (int i = 0; i < postdata.Length; i++)
                {
                    modeldel.product_id = postdata[i].Product_id;
                    modeldel.product_name = postdata[i].Product_name;
                    modeldel.quantity = postdata[i].Quantity;
                    modeldel.unit = postdata[i].Unit;
                    modeldel.price = postdata[i].Price;
                    modeldel.amount = postdata[i].Amount;

                    cod.Add(modeldel);
                }
            }

            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 ";
                }
                string issar = request["issarr"];
                if (issar == "1")
                {
                    serchtxt += " and isnull( arrears_money,0)>0";
                }

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

                if (!string.IsNullOrEmpty(request["contact"]))
                    serchtxt += " and Order_status_id = " + int.Parse(request["contact_val"]);

                if (!string.IsNullOrEmpty(request["department"]))
                    serchtxt += " and F_dep_id = " + int.Parse(request["department_val"]);

                if (!string.IsNullOrEmpty(request["employee"]))
                    serchtxt += " and F_emp_id = " + int.Parse(request["employee_val"]);

                if (!string.IsNullOrEmpty(request["startdate"]))
                    serchtxt += " and Order_date >= '" + PageValidate.InputText(request["startdate"], 255) + "'";

                if (!string.IsNullOrEmpty(request["enddate"]))
                {
                    DateTime enddate = DateTime.Parse(request["enddate"]);
                    serchtxt += " and Order_date <= '" + DateTime.Parse(request["enddate"]).AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }

                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 + "'";
                }

                //权限
                serchtxt += DataAuth(request.Cookies["UserID"].Value);
                DataSet ds = order.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }

            if (request["Action"] == "gridbycustomerid")
            {
                string customerid = request["customerid"];

                DataSet ds = order.GetList(0, " isDelete=0 and Customer_id =" + int.Parse(customerid), " Order_date desc");
                context.Response.Write(Common.GetGridJSON.DataTableToJSON(ds.Tables[0]));
            }
            if (request["Action"] == "form")
            {
                int pid = int.Parse(request["orderid"]);
                DataSet ds = order.GetList("id=" + pid);

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

                context.Response.Write(dt);
            }
            if (request["Action"] == "AdvanceDelete")
            {
                //参数安全过滤
                string c_id = request["id"];

                DataSet ds = order.GetList("id=" + c_id);

                BLL.CRM_contract contract = new BLL.CRM_contract();
                BLL.CRM_invoice invoice = new BLL.CRM_invoice();
                BLL.CRM_receive receive = new BLL.CRM_receive();
                if (invoice.GetList("order_id=" + c_id).Tables[0].Rows.Count > 0)
                {
                    //invoice
                    context.Response.Write("false:invoice");
                }
                else if (receive.GetList("order_id=" + c_id).Tables[0].Rows.Count > 0)
                {
                    //receive
                    context.Response.Write("false:receive");
                }
                else
                {
                    bool canedel = true;
                    if (uid != "admin")
                    {
                        Data.GetDataAuth dataauth = new Data.GetDataAuth();
                        string txt = dataauth.GetDataAuthByid("3", "Sys_del", emp_id.ToString());

                        string[] arr = txt.Split(':');
                        switch (arr[0])
                        {
                            case "none":
                                canedel = false;
                                break;
                            case "my":
                                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                {
                                    if (ds.Tables[0].Rows[i]["C_emp_id"].ToString() == arr[1])
                                        canedel = true;
                                    else
                                        canedel = false;
                                }
                                break;
                            case "dep":
                                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                {
                                    if (ds.Tables[0].Rows[i]["C_dep_id"].ToString() == arr[1])
                                        canedel = true;
                                    else
                                        canedel = false;
                                }
                                break;
                            case "all":
                                canedel = true;
                                break;
                        }
                    }
                    if (canedel)
                    {
                        bool isdel = order.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]["Customer_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("delfalse");
                    }
                }
            }

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

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

                for (int i = 0; i < arr.Length; i++)
                {
                    order.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]["Customer_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");
                }

            }

            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, "66");
                        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 = order.GetList("id in (" + idlist.Trim() + ")");

                    bool cando = true;

                    for (int i = 0; i < arr.Length; i++)
                    {
                        bool deleted = order.Delete(int.Parse(arr[i]));

                        if (!deleted)
                            cando = false;
                    }

                    if (cando)
                    {

                        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]["Customer_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");
                }
            }
        }