Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user = (User)Session["user"];
            permission();
            //获取供应商
            dsSupplier = bookbll.selectSupplier();
            //getData();
            //获取组织
            dsRegion = regionBll.select();
            string op = Request["op"];

            if (op == "paging")
            {
                getData();
            }
            if (op == "logout")
            {
                //删除身份凭证
                FormsAuthentication.SignOut();
                //设置Cookie的值为空
                Response.Cookies[FormsAuthentication.FormsCookieName].Value = null;
                //设置Cookie的过期时间为上个月今天
                Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取基础数据及查询方法
        /// </summary>
        /// <returns></returns>
        public string getData()
        {
            //获取分页数据
            int currentPage = Convert.ToInt32(Request["page"]);

            if (currentPage == 0)
            {
                currentPage = 1;
            }
            string search = Request["search"];

            if (search == "" || search == null)
            {
                search = "deleteState=0";
            }
            else
            {
                search = String.Format(" (customerName {0} or customerID {0}) and deleteState=0", "like '%" + search + "%'");
            }

            TableBuilder tb = new TableBuilder();

            tb.StrTable      = "T_Customer";
            tb.OrderBy       = "customerID";
            tb.StrColumnlist = "customerID,customerName,deleteState";
            tb.IntPageSize   = pageSize;
            tb.IntPageNum    = currentPage;
            tb.StrWhere      = search;
            //获取展示的客户数据
            ds = userbll.selectByPage(tb, out totalCount, out intPageCount);
            //获取地区下拉数据
            regionDs = rbll.select();
            //生成table
            StringBuilder strb = new StringBuilder();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                strb.Append("<tr><td>" + (i + 1 + ((currentPage - 1) * pageSize)) + "</td>");
                strb.Append("<td>" + ds.Tables[0].Rows[i]["customerID"].ToString() + "</td>");
                strb.Append("<td>" + ds.Tables[0].Rows[i]["customerName"].ToString() + "</td>");
                strb.Append("<td>" + "<button class='btn btn-warning btn-sm btn_Editor' data-toggle='modal' data-target='#myModa2'>" + "<i class='fa fa-pencil fa-lg'></i>" + "</button>");
                strb.Append("<button class='btn btn-danger btn-sm btn_delete'>" + "<i class='fa fa-trash-o fa-lg'></i>" + "</button>" + " </td></tr>");
            }
            strb.Append("<input type='hidden' value='" + intPageCount + "' id='intPageCount' />");
            string op = Request["op"];

            if (op == "paging")
            {
                Response.Write(strb.ToString());
                Response.End();
            }
            return(strb.ToString());
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = (User)Session["user"];

            userName   = user.UserName;
            regionName = user.ReginId.RegionName;
            string op = Request["op"];

            if (op == "paging")
            {
                getData();
            }
            if (op == "exportAll")
            {
                //export();
                exportAll();
            }
            if (op == "exportDe")
            {
                //exportDe();
                exportDetail();
            }
            else
            {
                permission();
                //获取供应商
                dsSupplier = bookBll.selectSupplier();
                //获取组织
                dsRegion = regionBll.select();
                //获取客户
                dsCustom = customBll.select();
            }
            if (op == "logout")
            {
                //删除身份凭证
                FormsAuthentication.SignOut();
                //设置Cookie的值为空
                Response.Cookies[FormsAuthentication.FormsCookieName].Value = null;
                //设置Cookie的过期时间为上个月今天
                Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1);
            }
            if (op == "print")
            {
                Response.Write(print());
                Response.End();
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            permission();
            //getData();
            User user = (User)Session["user"];

            regionId = user.ReginId.RegionId;
            roleName = user.RoleId.RoleName;
            //获取组织
            dsRegion = regionBll.select();
            //获取操作员
            dsUser = regionBll.selectUser();
            string op = Request["op"];

            if (op == "paging")
            {
                getData();
            }
            if (op == "logout")
            {
                //删除身份凭证
                FormsAuthentication.SignOut();
                //设置Cookie的值为空
                Response.Cookies[FormsAuthentication.FormsCookieName].Value = null;
                //设置Cookie的过期时间为上个月今天
                Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1);
            }
            else if (op == "add")
            {
                DateTime nowTime = DateTime.Now;
                string   nowDt   = nowTime.ToString("yyyy-MM-dd");
                long     count   = 0;
                //判断数据库中是否已经有记录
                DataSet backds = wareBll.getAllTime(1);
                if (backds != null && backds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < backds.Tables[0].Rows.Count; i++)
                    {
                        string   time    = backds.Tables[0].Rows[i]["time"].ToString();
                        DateTime dt      = Convert.ToDateTime(time);
                        string   sqlTime = dt.ToString("yyyy-MM-dd");
                        if (sqlTime == nowDt)
                        {
                            //count += 1;
                            string id    = backds.Tables[0].Rows[i]["singleHeadId"].ToString();
                            string st1   = id.Substring(10);
                            long   rowes = long.Parse(st1) + 1;
                            count = rowes;
                            break;
                        }
                        else
                        {
                            count = 1;
                            break;
                        }
                    }
                    if (count == 0)
                    {
                        count = 1;
                    }
                }
                else
                {
                    count = 1;
                }
                string source  = Request["source"];
                string remarks = Request["remarks"];
                if (remarks == "" || remarks == null)
                {
                    remarks = "";
                }
                SingleHead single = new SingleHead();
                Region     region = new Region();
                region.RegionId     = Convert.ToInt32(source);
                single.Region       = region;
                single.SingleHeadId = "RK" + DateTime.Now.Date.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                single.Time         = DateTime.Now;
                single.Type         = 1;
                single.User         = user;
                single.Remarks      = remarks;
                Result row = wareBll.insertHead(single);
                if (row == Result.添加成功)
                {
                    Response.Write("添加成功");
                    Response.End();
                }
                else
                {
                    Response.Write("添加失败");
                    Response.End();
                }
            }
            else if (op == "del")
            {
                string Id  = Request["account"];
                Result row = wareBll.deleteHead(Id, 1);
                if (row == Result.除成功)
                {
                    Response.Write("删除成功");
                    Response.End();
                }
                else
                {
                    Response.Write("删除失败");
                    Response.End();
                }
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string tjType       = Request["type"];
            string tjRegion     = Request["region"];
            string tjHeadId     = Request["singleHeadId"];
            string tjuserName   = Request["userName"];
            string tjtime       = Request["time"];
            string defaultWhere = "";

            if (tjRegion != "null" && tjRegion != "" && tjRegion != null)
            {
                if (defaultWhere == "")
                {
                    defaultWhere += "regionName='" + tjRegion + "'";
                }
                else
                {
                    defaultWhere += " and regionName='" + tjRegion + "'";
                }
            }
            if (tjHeadId != "null" && tjHeadId != "" && tjHeadId != null)
            {
                if (defaultWhere == "")
                {
                    defaultWhere += "singleHeadId='" + tjHeadId + "'";
                }
                else
                {
                    defaultWhere += " and singleHeadId='" + tjHeadId + "'";
                }
            }
            if (tjuserName != "null" && tjuserName != "" && tjuserName != null)
            {
                if (defaultWhere == "")
                {
                    defaultWhere += "userName='******'";
                }
                else
                {
                    defaultWhere += " and userName='******'";
                }
            }
            if (tjtime != "null" && tjtime != "" && tjtime != null)
            {
                if (defaultWhere == "")
                {
                    string[] sArray    = tjtime.Split('至');
                    string   startTime = sArray[0];
                    string   endTime   = sArray[1];
                    defaultWhere += "time BETWEEN '" + startTime + "' and '" + endTime + "'";
                }
                else
                {
                    string[] sArray    = tjtime.Split('至');
                    string   startTime = sArray[0];
                    string   endTime   = sArray[1];
                    defaultWhere += " and time BETWEEN '" + startTime + "' and '" + endTime + "'";
                }
            }
            int type = 0;

            if (tjType == "CK")
            {
                type  = 0;
                title = "接收组织";
            }
            if (tjType == "RK")
            {
                type  = 1;
                title = "入库来源";
            }
            if (tjType == "TH")
            {
                type  = 2;
                title = "接收组织";
            }
            User    user     = (User)Session["user"];
            string  userId   = user.UserId;
            DataSet ds       = roleBll.selectRole(userId);
            string  roleName = ds.Tables[0].Rows[0]["roleName"].ToString();
            DataSet dataSet  = warehousingBll.getKinds(type, defaultWhere);

            sjNum = dataSet.Tables[0].Rows[0]["pz"].ToString();
            sbNum = dataSet.Tables[0].Rows[0]["sl"].ToString();
            total = dataSet.Tables[0].Rows[0]["my"].ToString();
            real  = dataSet.Tables[0].Rows[0]["sy"].ToString();
            //string time = "2018-10-10";
            int region = user.ReginId.RegionId;

            if (roleName == "超级管理员")
            {
                isAdmin = true;
            }
            //getData();
            //获取供应商
            dsSupplier = bookbll.selectSupplier();
            //获取组织
            dsRegion = regionBll.select();
            //获取制单员
            dsUser = bookbll.selectZdy();
            //获取来源组织/收货组织
            dsSource = bookbll.selectSource();
            string op = Request["op"];

            if (op == "paging")
            {
                getData();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取基础数据
        /// </summary>
        /// <returns></returns>
        public string getData()
        {
            //获取分页数据
            User user        = (User)Session["user"];
            int  currentPage = Convert.ToInt32(Request["page"]);

            if (currentPage == 0)
            {
                currentPage = 1;
            }
            string goods  = Request["goods"];
            string region = Request["region"];
            string search;

            if ((region == "" || region == null) && (goods == "" || goods == null))
            {
                search = "";
            }
            else if ((goods != null || goods != "") && (region == "" || region == null))
            {
                search = String.Format("shelvesName like '%{0}%'", goods);
            }
            else if ((goods == null || goods == "") && (region != "" || region != null))
            {
                search = String.Format("regionName like '%{0}%'", region);
            }
            else
            {
                search = String.Format("regionName like '%{0}%' and shelvesName like '%{1}%'", region, goods);
            }

            TableBuilder tb = new TableBuilder();

            tb.StrTable      = "V_GoodsShelves";
            tb.OrderBy       = "goodsShelvesId";
            tb.StrColumnlist = "goodsShelvesId,shelvesName,regionId,regionName";
            tb.IntPageSize   = PageSize;
            tb.IntPageNum    = currentPage;
            if (user.RoleId.RoleName == "超级管理员")
            {
                tb.StrWhere = search;
            }
            else
            {
                if (search == "" || search == null)
                {
                    tb.StrWhere = "regionId=" + user.ReginId.RegionId;
                }
                else
                {
                    tb.StrWhere = "regionId=" + user.ReginId.RegionId + " and " + search;
                }
            }
            //获取展示的客户数据
            ds = shelvesbll.selectByPage(tb, out totalCount, out intPageCount);
            //获取地区下拉数据
            regionDs = rbll.select();
            //生成table
            StringBuilder strb = new StringBuilder();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                strb.Append("<tr><td>" + (i + 1 + ((currentPage - 1) * PageSize)) + "</td>");
                strb.Append("<td>" + ds.Tables[0].Rows[i]["shelvesName"].ToString() + "</td>");
                strb.Append("<td>" + ds.Tables[0].Rows[i]["goodsShelvesId"].ToString() + "</td>");
                strb.Append("<td>" + ds.Tables[0].Rows[i]["regionName"].ToString() + "</td>");
                strb.Append("<td>" + "<button class='btn btn-danger btn-sm btn_delete'>" + "<i class='fa fa-trash-o fa-lg'></i>" + "</button>" + " </td></tr>");
            }
            strb.Append("<input type='hidden' value='" + intPageCount + "' id='intPageCount' />");
            string op = Request["op"];

            if (op == "paging")
            {
                Response.Write(strb.ToString());
                Response.End();
            }
            return(strb.ToString());
        }
Ejemplo n.º 7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            RegionBll        regionBll = new RegionBll();
            UserBll          userBll   = new UserBll();
            RoleBll          roleBll   = new RoleBll();
            RSACryptoService rsa       = new RSACryptoService();

            string roleName = "微信零售";
            int    row      = roleBll.selectByroleName(roleName);
            int    roleId   = 0;

            if (row <= 0)
            {
                Role role = new Role();
                role.RoleName = roleName;
                Result insert = roleBll.Insert(role);
                if (insert == Result.添加成功)
                {
                    roleId = roleBll.selectByroleName(roleName);
                    string sqlText = "(" + roleId + "," + 14 + ")";
                    Result inserts = roleBll.InsertPer(sqlText, roleId, "添加");
                    if (inserts == Result.添加失败)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                }
            }
            else
            {
                roleId = row;
            }
            DataSet ds    = regionBll.select();
            int     count = ds.Tables[0].Rows.Count;

            if (count > 0 && ds != null)
            {
                for (int i = 0; i < count; i++)
                {
                    string regionId   = ds.Tables[0].Rows[i]["regionId"].ToString();
                    string regionName = ds.Tables[0].Rows[i]["regionName"].ToString();
                    Region region     = new Region();
                    region.RegionId = Convert.ToInt32(regionId);
                    Role role = new Role();
                    role.RoleId = roleId;
                    User user = new User();
                    user.UserId   = regionId + "01";
                    user.UserName = regionName + "微信零售";
                    user.ReginId  = region;
                    user.Pwd      = rsa.Encrypt("000000");
                    user.RoleId   = role;
                    Result rows = userBll.Insert(user);
                    if (rows == Result.添加失败)
                    {
                        Response.Write("添加失败:" + regionId);
                    }
                }
                Response.Write("添加成功");
            }
            else
            {
                Response.Write("未查到任何组织信息");
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取数据
        /// </summary>
        protected string getData()
        {
            User user = (User)Session["user"];

            currentPage = Convert.ToInt32(Request["page"]);
            if (currentPage == 0)
            {
                currentPage = 1;
            }
            string userName = Request["userName"];
            string region   = Request["region"];
            string role     = Request["role"];

            if ((userName == "" || userName == null) && (region == null || region == "") && (role == null || role == ""))
            {
                search = "deleteState=0";
            }
            else if ((userName != "" && userName != null) && (region == null || region == "") && (role == null || role == ""))
            {
                search = String.Format(" userName like '%{0}%' and deleteState=0", userName);
            }
            else if ((userName == "" || userName == null) && (region != "" && region != null) && (role == null || role == ""))
            {
                search = "regionName like '%" + region + "%'  and deleteState=0";
            }
            else if ((userName == "" || userName == null) && (role != "" && role != null) && (region == null || region == ""))
            {
                search = "roleName like '%" + role + "%'  and deleteState=0";
            }
            else if ((userName == "" || userName == null) && (role != "" && role != null) && (region != null && region != ""))
            {
                search = "regionName like '%" + region + "%' and roleName like '%" + role + "%'  and deleteState=0";
            }
            else if ((userName != "" && userName != null) && (region != null && region != "") && (role == null || role == ""))
            {
                search = String.Format(" userName like '%{0}%' and regionName like '%{1}%'  and deleteState=0", userName, region);
            }
            else if ((userName != "" && userName != null) && (region == null || region == "") && (role != null && role != ""))
            {
                search = String.Format(" userName like '{0}' and roleName like '%{1}%'  and deleteState=0", userName, role);
            }
            else
            {
                search = String.Format(" userName like '{0}' and regionName like '%{1}%' and roleName like '%{2}%'  and deleteState=0", userName, region, role);
            }
            //获取分页数据
            TableBuilder tbd = new TableBuilder();

            tbd.StrTable      = "V_User";
            tbd.OrderBy       = "userID";
            tbd.StrColumnlist = "userID,userName,regionName,roleName,regionId,roleId";
            tbd.IntPageSize   = pageSize;
            if (user.RoleId.RoleName == "超级管理员")
            {
                tbd.StrWhere = search;
            }
            else
            {
                tbd.StrWhere = "regionId=" + user.ReginId.RegionId + " and " + search;
            }
            tbd.IntPageNum = currentPage;
            //获取展示的用户数据
            ds       = userBll.selectByPage(tbd, out totalCount, out intPageCount);
            dsRegion = regionBll.select();
            dsRole   = roleBll.select();
            //生成table
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                sb.Append("<tr><td>" + (i + 1 + ((currentPage - 1) * pageSize)) + "</td>");
                sb.Append("<td>" + ds.Tables[0].Rows[i]["userID"].ToString() + "</td></td>");
                sb.Append("<td>" + ds.Tables[0].Rows[i]["userName"].ToString() + "</ td >");
                sb.Append("<td>" + ds.Tables[0].Rows[i]["regionName"].ToString() + "</ td >");
                sb.Append("<td>" + ds.Tables[0].Rows[i]["roleName"].ToString() + "</ td >");
                sb.Append("<td><input type='hidden' value=" + ds.Tables[0].Rows[i]["regionId"].ToString() + " class='regionId' />");
                sb.Append("<input type='hidden' value=" + ds.Tables[0].Rows[i]["roleId"].ToString() + " class='roleId' />");
                sb.Append("<button class='btn btn-warning btn-sm btn-edit' data-toggle='modal' data-target='#myModa2'><i class='fa fa-pencil fa-lg'></i></button>");
                sb.Append("<button class='btn btn-danger btn-sm btn-delete'><i class='fa fa-trash-o fa-lg'></i></button></td></ tr >");
            }
            sb.Append("<input type='hidden' value='" + intPageCount + "' id='intPageCount' />");
            string op = Request["op"];

            if (op == "paging")
            {
                Response.Write(sb.ToString());
                Response.End();
            }
            return(sb.ToString());
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                permission();
                User user = (User)Session["user"];
                operatorId = user.UserId.ToString();
            }
            RegionBll        regBll = new RegionBll();
            ConfigurationBll cBll   = new ConfigurationBll();
            Result           result;

            regionds = regBll.select();
            string op = Request["op"];

            if (op == "sure")
            {
                string startTime  = Request["startDt"].ToString(),
                       endTime    = Request["endDt"].ToString(),
                       regionName = Request["regName"].ToString();
                string   type     = Request["type"].ToString();
                DateTime st       = DateTime.Parse(startTime);
                DateTime et       = DateTime.Parse(endTime);
                result = cBll.isExist(regionName);
                if (result == Result.记录不存在)
                {
                    result = cBll.Insert(st, et, regionName, type);
                    if (result == Result.添加成功)
                    {
                        Response.Write("添加成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                }
                else
                {
                    result = cBll.Update(st, et, regionName, type);
                    if (result == Result.更新成功)
                    {
                        Response.Write("更新成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("更新失败");
                        Response.End();
                    }
                }
            }
            if (op == "goScreen")
            {
                string regionName = Request["regName"].ToString();
                if (regionName == "选择组织" || regionName == null)
                {
                    User user = (User)Session["user"];
                    regionName = user.ReginId.RegionName;
                }
                Session["regionName"] = regionName;
                result = cBll.isExist(regionName);
                if (result == Result.记录不存在)
                {
                    Response.Write("记录不存在");
                    Response.End();
                }
                else
                {
                    Response.Write("记录存在");
                    Response.End();
                }
            }
            if (op == "logout")
            {
                //删除身份凭证
                FormsAuthentication.SignOut();
                //设置Cookie的值为空
                Response.Cookies[FormsAuthentication.FormsCookieName].Value = null;
                //设置Cookie的过期时间为上个月今天
                Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1);
            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user = (User)Session["user"];
            permission();
            //获取组织
            dsRegion = regionBll.select();
            //获取操作员
            dsUser = saleheadbll.selectCzy();
            string op = Request["op"];

            saleTaskid = Session["saleId"].ToString();
            SaleTaskBll saleBll = new SaleTaskBll();

            finishTime = saleBll.getSaleTaskFinishTime(saleTaskid);
            //getData();
            if (op == "paging")
            {
                getData();
            }
            string saleheadId = Request["ID"];

            type = Session["type"].ToString();
            //添加销售单体
            if (op == "addDetail")
            {
                if (finishTime != null && finishTime != "")
                {
                    Response.Write("该销售计划已完成");
                    Response.End();
                }
                else
                {
                    SaleMonomerBll salemonbll = new SaleMonomerBll();
                    int            state      = salemonbll.saleheadstate(saleTaskid, saleheadId);
                    if (state == 2)
                    {
                        Response.Write("失败");
                        Response.End();
                    }
                    else
                    {
                        Session["saleheadId"] = saleheadId;
                        Session["saleType"]   = "addsale";
                        Response.Write("成功");
                        Response.End();
                    }
                }
            }
            //if (op == "saleback")
            //{
            //    saleback();
            //}
            if (op == "Settlement")
            {
                string salehead = Request["ID"];
                string taskId   = Request["taskId"];
                Settlement(taskId, salehead, 0);
            }
            if (op == "SettlementAll")
            {
                SettlementAll();
            }
            if (op == "logout")
            {
                //删除身份凭证
                FormsAuthentication.SignOut();
                //设置Cookie的值为空
                Response.Cookies[FormsAuthentication.FormsCookieName].Value = null;
                //设置Cookie的过期时间为上个月今天
                Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1);
            }
            //查看
            if (op == "look")
            {
                string type = Request["type"];
                Session["type"]       = type;
                Session["saleheadId"] = saleheadId;
                Session["saleType"]   = "look";
                Response.Write("成功");
                Response.End();
            }
            //完成此销售任务
            if (op == "finish")
            {
                //判断该销售任务下是否还有未完成单据0新建单据 1未完成,2完成,3未结算
                SaleTaskBll salebll         = new SaleTaskBll();
                DataSet     saleHeadStateds = salebll.SelectHeadStateBySaleId(saleTaskid);
                int         count           = saleHeadStateds.Tables[0].Rows.Count;
                int         state           = 4;
                for (int i = 0; i < count; i++)
                {
                    state = Convert.ToInt32(saleHeadStateds.Tables[0].Rows[i]["state"]);
                    if (state == 0 || state == 1)
                    {
                        break;
                    }
                }
                if (state == 0)
                {
                    Response.Write("失败,有新建的单据");
                    Response.End();
                }
                if (state == 1)
                {
                    Response.Write("失败,有采集中的单据");
                    Response.End();
                }
                else
                {
                    DateTime finishTime = DateTime.Now.ToLocalTime();
                    int      row        = salebll.updatefinishTime(finishTime, saleTaskid);
                    if (row > 0)
                    {
                        Response.Write("成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("失败");
                        Response.End();
                    }
                }
                //if (state < 2)
                //{
                //    Response.Write("未完成失败");
                //    Response.End();
                //}
                //else if (state == 2)
                //{
                //    DateTime finishTime = DateTime.Now.ToLocalTime();
                //    int row = salebll.updatefinishTime(finishTime, saleTaskid);
                //    if (row > 0)
                //    {
                //        Response.Write("成功");
                //        Response.End();
                //    }
                //    else
                //    {
                //        Response.Write("失败");
                //        Response.End();
                //    }
                //}
            }
            //添加
            if (op == "add")
            {
                //获取销售任务的状态
                SaleHeadBll saleheadbll = new SaleHeadBll();
                SaleHead    salehead    = new SaleHead();
                string      remarks     = Request["remarks"];
                if (remarks == "" || remarks == null)
                {
                    remarks = "";
                }
                string saleId = Session["saleId"].ToString();
                string SaleHeadId;
                int    count = saleheadbll.getCount();
                if (count > 0)
                {
                    string time       = saleheadbll.getSaleHeadTime();
                    string nowTime    = DateTime.Now.ToLocalTime().ToString();
                    string equalsTime = DateTime.Now.ToLocalTime().ToString("yyyyMMdd");
                    if (time.Equals(equalsTime))
                    {
                        nowTime = DateTime.Now.ToString("yyyy-MM-dd");
                        string getheadId = saleheadbll.getSaleHeadIdByTime(nowTime);
                        if (getheadId == "" || getheadId == null)
                        {
                            count      = 1;
                            SaleHeadId = "XS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                        }
                        else
                        {
                            string js = getheadId.Remove(0, getheadId.Length - 6);
                            count      = Convert.ToInt32(js) + 1;
                            SaleHeadId = "XS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                        }
                    }
                    else
                    {
                        count      = 1;
                        SaleHeadId = "XS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                    }
                }
                else
                {
                    count      = 1;
                    SaleHeadId = "XS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                }
                salehead.SaleHeadId    = SaleHeadId;
                salehead.SaleTaskId    = saleId;
                salehead.KindsNum      = 0;
                salehead.Number        = 0;
                salehead.AllTotalPrice = 0;
                salehead.AllRealPrice  = 0;
                User user = (User)Session["user"];
                salehead.UserId   = user.UserId;
                salehead.RegionId = user.ReginId.RegionId;
                salehead.DateTime = DateTime.Now.ToLocalTime();
                salehead.State    = 0;
                salehead.Remarks  = remarks;
                Result result = saleheadbll.Insert(salehead);
                if (result == Result.添加成功)
                {
                    Response.Write("添加成功");
                    Response.End();
                }
                else
                {
                    Response.Write("添加失败");
                    Response.End();
                }
            }
            //删除
            if (op == "del")
            {
                string         salehead   = Request["ID"];
                string         headstate  = Request["state"];
                SaleMonomerBll salemonbll = new SaleMonomerBll();
                int            state;
                if (headstate == "预采")
                {
                    state = salemonbll.perSaleheadstate(saleTaskid, salehead);
                }
                else
                {
                    state = salemonbll.saleheadstate(saleTaskid, salehead);
                }

                if (state == 0)
                {
                    Result result = salemonbll.realDelete(saleTaskid, salehead);
                    if (result == Result.除成功)
                    {
                        Response.Write("删除成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("删除失败");
                        Response.End();
                    }
                }
                else if (state == 1)
                {
                    Response.Write("单据采集中");
                    Response.End();
                }
                else if (state == 2)
                {
                    Response.Write("单据完成");
                    Response.End();
                }
                else if (state == 3)
                {
                    int count = salemonbll.WeChatSelectcountbyHeadID(salehead, saleTaskid);
                    if (count > 0)
                    {
                        Response.Write("该预采单已有数据,不能删除");
                        Response.End();
                    }
                    else
                    {
                        Result result = salemonbll.DeleteHead(saleTaskid, salehead, "copy");
                        if (result == Result.除成功)
                        {
                            Response.Write("删除成功");
                            Response.End();
                        }
                        else
                        {
                            Response.Write("删除失败");
                            Response.End();
                        }
                    }
                    //Result result = salemonbll.realDeleteHeadAndMon(saleTaskid, salehead);
                    //if (result == Result.删除成功)
                    //{
                    //    Response.Write("删除成功");
                    //    Response.End();
                    //}
                    //else
                    //{
                    //    Response.Write("删除失败");
                    //    Response.End();
                    //}
                }
                else
                {
                    Response.Write("删除失败");
                    Response.End();
                }
            }
        }