Exemplo n.º 1
0
        private void changeNum(HttpContext context)
        {
            SaleHeadBll saleheadbll = new SaleHeadBll();
            string      SaleHeadId  = context.Request["saleheadID"];
            string      saleId      = context.Request["saletaskID"];
            int         number      = Convert.ToInt32(context.Request["number"]);
            string      bookNum     = context.Request["bookNum"].ToString();
            DataSet     bookNumds;

            if (teamtype == "team")
            {
                bookNumds = salemonbll.getsalemonDetail(SaleHeadId, saleId, bookNum);
            }
            else
            {
                bookNumds = salemonbll.getPersalemonDetail(SaleHeadId, saleId, bookNum);
            }

            if (number < 0)
            {
                number = Math.Abs(number);
                if (bookNumds != null)
                {
                    int booknumber = int.Parse(bookNumds.Tables[0].Rows[0]["number"].ToString());
                    if (number > booknumber)
                    {
                        context.Response.Write("输入的负数不能大于已购数量,已购数为:" + booknumber);
                        context.Response.End();
                    }
                    else
                    {
                        number = number * -1;
                        addsalemon(context);
                    }
                }
            }
            else
            {
                addsalemon(context);
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user   = (User)Session["user"];
            type   = Session["saleType"].ToString();
            saleId = Session["saleId"].ToString();
            //getData();
            getlimt();
            SaleTask task = saletaskbll.selectById(saleId);

            defaultdiscount = task.DefaultDiscount.ToString();
            SaleHeadId      = Session["saleheadId"].ToString();

            //更新单头
            updateSalehead();
            string op = Request["op"];

            //isbn回车
            if (op == "search")
            {
                string ISBN = Request["ISBN"];
                bookds = bookbll.SelectByIsbn(ISBN);
                if (bookds != null)
                {
                    //如果有两条及两条以上显示表格
                    if (bookds.Tables[0].Rows.Count > 1)
                    {
                        getbook();
                    }
                    //只有一条数据
                    else
                    {
                        backbook();
                    }
                }
                else
                {
                    Response.Write("无数据");
                    Response.End();
                }
            }
            //一书多号选择后执行
            if (op == "add")
            {
                showBook();
            }
            //添加销售
            if (op == "addsale")
            {
                SaleHeadBll saleheadbll   = new SaleHeadBll();
                string      saletaskId    = saleheadbll.SelectTaskByheadId(SaleHeadId);
                string      customerId    = saletaskbll.getCustomerId(saletaskId);
                int         AlreadyBought = user.ReginId.RegionId;
                //判断馆藏
                LibraryCollectionBll library = new LibraryCollectionBll();
                bookISBN = Request["bookISBN"];
                Result libresult = library.Selectbook(customerId, bookISBN);
                if (libresult == Result.记录不存在)
                {
                    bookISBN = Request["bookISBN"];
                    disCount = double.Parse(Request["discount"]);
                    number   = Convert.ToInt32(Request["number"]);
                    bookNum  = Request["bookNum"].ToString();
                    if (number < 0)
                    {
                        number = Math.Abs(number);
                        DataSet bookNumds = salemonbll.getsalemonDetail(SaleHeadId, saleId, bookNum);
                        if (bookNumds != null)
                        {
                            int booknumber = int.Parse(bookNumds.Tables[0].Rows[0]["number"].ToString());
                            if (number > booknumber)
                            {
                                msg.Messege = "输入的负数不能大于已购数量,已购数为:" + booknumber;
                                Response.Write(ObjectToJson(msg));
                                Response.End();
                            }
                            else
                            {
                                number = number * -1;
                                addsalemon();
                            }
                        }
                        else
                        {
                            msg.Messege = "该书籍没有购买过,数量不能为负数";
                            Response.Write(ObjectToJson(msg));
                            Response.End();
                        }
                    }
                    else
                    {
                        addsalemon();
                    }
                }
                else
                {
                    msg.Messege = "客户馆藏已存在";
                    Response.Write(ObjectToJson(msg));
                    Response.End();
                }
            }
            //客户馆藏已存在,继续录入
            if (op == "addRsMon")
            {
                bookISBN = Request["bookISBN"];
                disCount = double.Parse(Request["discount"]);
                number   = Convert.ToInt32(Request["number"]);
                bookNum  = Request["bookNum"].ToString();
                if (number < 0)
                {
                    number = Math.Abs(number);
                    DataSet bookNumds = salemonbll.getsalemonDetail(SaleHeadId, saleId, bookNum);
                    if (bookNumds != null)
                    {
                        int booknumber = int.Parse(bookNumds.Tables[0].Rows[0]["number"].ToString());
                        if (number > booknumber)
                        {
                            msg.Messege = "输入的负数不能大于已购数量,已购数为:" + booknumber;
                            Response.Write(ObjectToJson(msg));
                            Response.End();
                        }
                        else
                        {
                            number = number * -1;
                            addsalemon();
                        }
                    }
                    else
                    {
                        msg.Messege = "该书籍没有购买过,数量不能为负数";
                        Response.Write(ObjectToJson(msg));
                        Response.End();
                    }
                }
                else
                {
                    addsalemon();
                }
            }
            //完成单据
            if (op == "success")
            {
                //判断是否有单体
                int row = salemonbll.SelectBySaleHeadId(SaleHeadId);
                if (row > 0)
                {
                    //修改单头状态为2
                    Result result = salemonbll.updateHeadstate(saleId, SaleHeadId, 2);
                    if (result == Result.更新成功)
                    {
                        Response.Write("状态修改成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("状态修改失败");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("没有数据");
                    Response.End();
                }
            }
            //返回按钮
            if (op == "back")
            {
                updateSalehead();
                int row = salemonbll.SelectBySaleHeadId(SaleHeadId);
                if (row > 0)
                {
                    string state = salemonbll.getsaleHeadState(SaleHeadId, saleId);
                    if (state == "0")
                    {
                        Result res = salemonbll.updateHeadstate(saleId, SaleHeadId, 1);
                        if (res == Result.更新成功)
                        {
                            Response.Write("更新成功");
                            Response.End();
                        }
                        else
                        {
                            Response.Write("更新失败");
                            Response.End();
                        }
                    }
                    else
                    {
                        Response.Write("无数据");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("无数据");
                    Response.End();
                }
            }
        }
Exemplo n.º 3
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();
                }
            }
        }
Exemplo n.º 4
0
        private void addsale(HttpContext context)
        {
            SaleHeadBll saleheadbll = new SaleHeadBll();
            string      SaleHeadId  = context.Request["saleheadID"];
            string      saleId      = context.Request["saletaskID"];
            int         number      = Convert.ToInt32(context.Request["number"]);
            string      bookNum     = context.Request["bookNum"].ToString();
            string      type        = context.Request["type"];
            string      saletype    = context.Request["saletype"];
            DataSet     bookNumds;

            if (teamtype == "team")
            {
                bookNumds = salemonbll.getsalemonDetail(SaleHeadId, saleId, bookNum);
            }
            else
            {
                bookNumds = salemonbll.getPersalemonDetail(SaleHeadId, saleId, bookNum);
            }
            if (bookNumds != null && bookNumds.Tables[0].Rows.Count > 0 && type != "continue")
            {
                context.Response.Write("已购买");
                context.Response.End();
            }
            else
            {
                if (isexites(saleId, bookNum) && saletype != "continue")
                {
                    context.Response.Write("以销售");
                    context.Response.End();
                }
                else
                {
                    if (number < 0)
                    {
                        number = Math.Abs(number);
                        if (bookNumds != null)
                        {
                            int booknumber = int.Parse(bookNumds.Tables[0].Rows[0]["number"].ToString());
                            if (number > booknumber)
                            {
                                context.Response.Write("输入的负数不能大于已购数量,已购数为:" + booknumber);
                                context.Response.End();
                            }
                            else
                            {
                                number = number * -1;
                                addsalemon(context);
                            }
                        }
                        else
                        {
                            context.Response.Write("该书籍没有购买过,数量不能为负数");
                            context.Response.End();
                        }
                    }
                    else
                    {
                        addsalemon(context);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="context"></param>
        private void addHead(HttpContext context)
        {
            string      customeID   = context.Request["customID"];
            string      saleId      = context.Request["saletaskID"];
            UserBll     user        = new UserBll();
            DataSet     userds      = user.selectByUserId(customeID);
            int         regionId    = Convert.ToInt32(userds.Tables[0].Rows[0]["regionId"]);
            SaleHeadBll saleheadbll = new SaleHeadBll();
            SaleHead    salehead    = new SaleHead();
            string      SaleHeadId;
            int         count;
            string      type = context.Request["type"];

            if (type == "team")
            {
                count = saleheadbll.getCount();
            }
            else
            {
                count = saleheadbll.WeChatcountHead();
            }
            if (count > 0)
            {
                string time;
                if (type == "team")
                {
                    time = saleheadbll.getSaleHeadTime();
                }
                else
                {
                    time = saleheadbll.getPerSaleHeadTime();
                }
                string nowTime    = DateTime.Now.ToLocalTime().ToString();
                string equalsTime = DateTime.Now.ToLocalTime().ToString("yyyyMMdd");
                if (time.Equals(equalsTime))
                {
                    string getheadId;
                    nowTime = DateTime.Now.ToString("yyyy-MM-dd");
                    if (type == "team")
                    {
                        getheadId = saleheadbll.getSaleHeadIdByTime(nowTime);
                    }
                    else
                    {
                        getheadId = saleheadbll.getPerSaleHeadIdByTime(nowTime);
                    }

                    if (getheadId == "" || getheadId == null)
                    {
                        count      = 1;
                        SaleHeadId = "WXS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                    }
                    else
                    {
                        string js = getheadId.Remove(0, getheadId.Length - 6);
                        count      = Convert.ToInt32(js) + 1;
                        SaleHeadId = "WXS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                    }
                }
                else
                {
                    count      = 1;
                    SaleHeadId = "WXS" + DateTime.Now.ToString("yyyyMMdd") + count.ToString().PadLeft(6, '0');
                }
            }
            else
            {
                count      = 1;
                SaleHeadId = "WXS" + 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;
            salehead.UserId        = customeID;
            salehead.RegionId      = regionId;
            salehead.DateTime      = DateTime.Now.ToLocalTime();
            Result result;

            if (type == "team")
            {
                salehead.State = 0;
                result         = saleheadbll.Insert(salehead);
            }
            else
            {
                salehead.State = 3;
                result         = saleheadbll.perInsert(salehead);
            }

            if (result == Result.添加成功)
            {
                context.Response.Write("添加成功");
                context.Response.End();
            }
            else
            {
                context.Response.Write("添加失败");
                context.Response.End();
            }
        }