public override int Update(BaseSearchModel model)
        {
            try
            {
                foreach (RWBarcodeModel item in RWBarcodeModels)
                {
                    //修改条码信息
                    ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>();
                    item.Status = Status;
                    adoBarcode.Update(item);

                    //添加条码历史记录
                    ModelAdo<RWHistoryModel> adoBarcodeHistroy = new ModelAdo<RWHistoryModel>();
                    RWHistoryModel historyModel = new RWHistoryModel()
                    {
                        CreateTime = DateTime.Now,
                        BillID = "",
                        BarcodeID = item.ID,
                        Remark = Remark
                    };
                    adoBarcodeHistroy.Insert(historyModel);
                }
            }
            catch (Exception)
            {
                return 0;
            }

            return 1;
        }
Beispiel #2
0
        /// <summary>
        /// token 信息,获取token详细信息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public UserTokenModel getUserToken(string accessToken)
        {
            userTokenModel = new ModelAdo <Model.UserTokenModel>();
            UserTokenModel model = userTokenModel.GetModel(" accessToken=?accessToken ", "", new MySqlParameter("?accessToken", accessToken));

            return(model);
        }
Beispiel #3
0
 // POST api/values
 public List<UserModel> Post()
 {
     List<UserModel> model = this.Request.Content.ReadAsAsync<List<UserModel>>().Result;
     HttpRequestMessage rm = this.Request;
     ModelAdo<UserModel> mUser = new ModelAdo<UserModel>();
     return mUser.GetList("", "", "");
 }
        public override BaseSearchModel Insert()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                //修改条码中对应装箱ID信息
                ModelAdo<RWBarcodeModel> apiBarcode = new ModelAdo<RWBarcodeModel>();
                //添加历史记录
                ModelAdo<RWHistoryModel> adoBarcodeHistroy = new ModelAdo<RWHistoryModel>();
                foreach (RWBarcodeModel item in RWBarcodeModels)
                {
                    item.BoxID = packingModel.ID;
                    apiBarcode.Update(item);

                    //创建条码历史记录【Add】
                    RWHistoryModel historyModel = new RWHistoryModel()
                    {
                        CreateTime = DateTime.Now,
                        BillID = "",
                        BarcodeID = item.ID,
                        Remark = Remark
                    };
                    adoBarcodeHistroy.Insert(historyModel);
                }

                //修改barcode的条码状态
                ModelAdo<PackingModel> apiPacking = new ModelAdo<PackingModel>();
                packingModel.Status = 2;
                apiPacking.Update(packingModel);

                ts.Complete();
            }
            return this;
        }
Beispiel #5
0
        public override BaseSearchModel Insert()
        {
            if (ids == null || ids.Length == 0)
            {
                throw new Exception("请输入待重置的用户信息");
            }
            else
            {
                using (TransactionScope ts = new TransactionScope())
                {

                    ModelAdo<LoginHistoryModel> adoUser = new ModelAdo<LoginHistoryModel>();
                    StringBuilder sb = new StringBuilder();
                    foreach (string item in ids)
                    {
                        sb.Append(",'" + item + "'");
                    }
                    sb.Remove(0, 1);

                    string sql = @"update UR05 set UR05005 =0 where UR05002 in( [UIDS] )";
                    sql = sql.Replace("[UIDS]", sb.ToString());
                    adoUser.ExecuteSql(sql, null);
                    ts.Complete();
                    return this;
                }

            }
        }
Beispiel #6
0
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
            {
                throw new Exception("请扫描或输入领料单对应的条码标签");
            }
            else if (string.IsNullOrEmpty(ReceiveId))
            {
                throw new Exception("请扫描或输入领料单的条码标签");
            }
            else
            {
                ModelAdo<ReceiveModel> adoReceive = new ModelAdo<ReceiveModel>();
                ReceiveModel receiveModel = adoReceive.GetModel(ReceiveId);
                if (receiveModel == null)
                {
                    throw new Exception("领料单不存在");
                }
                else
                {

                }
            }
            return base.Insert();
        }
Beispiel #7
0
        public override BaseSearchModel Insert()
        {
            if (String.IsNullOrEmpty(BarcodeID))
                throw new Exception("请扫描或输入待入库的条码标签");
            else
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    string sql = @"INSERT INTO [RW12]([RW12002],[RW12003],[RW12004],[RW12005],[RW12006])
             VALUES
               (GETDATE() ,@UserID ,@UserName,@PlanID,@Barcode);";

                    ModelAdo<CheckModel> adoRW = new ModelAdo<CheckModel>();
                    int count = adoRW.ExecuteSql(sql, new SqlParameter("@UserID", this.LoginUserID),
                        new SqlParameter("@UserName", this.LoginUserName),
                        new SqlParameter("@PlanID", ""),
                        new SqlParameter("@Barcode", this.BarcodeID));
                    if (count == 0)
                    {
                        throw new Exception("插入失败");
                    }
                    ts.Complete();
                    return this;
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// token 信息,获取token详细信息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public UserTokenModel getUserToken(int uid)
        {
            userTokenModel = new ModelAdo <Model.UserTokenModel>();
            UserTokenModel model = userTokenModel.GetModel(" uid=?uid ", "", new MySqlParameter("?uid", uid));

            return(model);
        }
 public override void OnLoad(HttpContext context)
 {
     base.OnLoad(context);
     requestBody             = new RequestBody();
     requestBody.accessToken = context.Request["accessToken"];
     requestBody.page        = Convert.ToInt32(context.Request["page"]);
     requestBody.pageSize    = Convert.ToInt32(context.Request["pageSize"]);
     requestBody.oid         = Convert.ToInt32(context.Request["oid"]);
     if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid == 0)
     {
         SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
     }
     else
     {
         //验证用户
         TokenHelper    token          = new TokenHelper();
         UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
         if (userTokenModel == null)
         {
             SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
         }
         else
         {
             ModelAdo <OrderSupplierModel> orderModel = new ModelAdo <OrderSupplierModel>();
             List <OrderSupplierModel>     models     = null;
             int pagenumber = requestBody.page == 0 ? 1 : requestBody.page;
             int totalCount = 1;
             orderModel.PageSize = requestBody.pageSize == 0 ? orderModel.PageSize : requestBody.pageSize;
             if (requestBody.oid == 0)
             {
                 models = orderModel.GetList(pagenumber, " cuid=?cuid ", "", out totalCount, "",
                                             new MySqlParameter("?cuid", userTokenModel.uid)
                                             );
             }
             else
             {
                 models = orderModel.GetList(pagenumber, " cuid=?cuid AND oid=?oid", "", out totalCount, "",
                                             new MySqlParameter("?cuid", Convert.ToInt32(userTokenModel.uid)),
                                             new MySqlParameter("?oid", requestBody.oid)
                                             );
             }
             if (models.Count >= 1)
             {
                 responseBody = new ResponseBody
                 {
                     page      = 1,
                     pageTotal = (totalCount + orderModel.PageSize - 1) / orderModel.PageSize,
                     total     = totalCount,
                     suppliers = models
                 };
                 responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
             }
             else
             {
                 SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
             }
         }
     }
 }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.userName    = context.Request["userName"];
            requestBody.userPwd     = context.Request["userPwd"];
            requestBody.userType    = context.Request["userType"];
            requestBody.bpuserid    = context.Request["bpuserid"];
            requestBody.channelid   = context.Request["channelid"];
            requestBody.deviceToken = context.Request["deviceToken"];
            requestBody.deviceType  = context.Request["deviceType"];
            if (requestBody.userType == null || requestBody.userName == null || requestBody.userPwd == null)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                string password = StringHelper.StringToMD5(requestBody.userPwd);
                ModelAdo <UserModel> userModel = new ModelAdo <UserModel>();
                UserModel            model     = userModel.GetModel(" rid=?rid and name =?name and password=?password", "",
                                                                    new MySqlParameter("?rid", requestBody.userType),
                                                                    new MySqlParameter("?name", requestBody.userName),
                                                                    new MySqlParameter("?password", password));

                if (model == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_LOGIN_ERROR, out statusCode, out responseJson);
                }
                else
                {
                    DateTime       dt             = DateTime.Now;
                    string         accessToken    = StringHelper.StringToMD5(dt.ToString());
                    TokenHelper    token          = new TokenHelper();
                    UserTokenModel modelUserToken = new UserTokenModel();
                    modelUserToken.uid         = model.id.ToString();
                    modelUserToken.rid         = model.rid;
                    modelUserToken.accessToken = accessToken;
                    modelUserToken.bpuserId    = requestBody.bpuserid;
                    modelUserToken.channelId   = requestBody.channelid;
                    modelUserToken.deviceToken = requestBody.deviceToken;
                    modelUserToken.deviceType  = Convert.ToInt32(requestBody.deviceType);
                    modelUserToken.loginTime   = StringHelper.ConvertDateTimeInt(DateTime.Now);
                    modelUserToken.isLogin     = 1;
                    token.updateToken(modelUserToken);

                    responseBody = new ResponseBody
                    {
                        accessToken = accessToken,
                        uid         = model.id.ToString(),
                        userName    = model.name,
                        nickName    = model.nickname,
                        userAvatar  = model.avatar,
                        userType    = model.rid
                    };
                    responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
                }
            }
        }
Beispiel #11
0
        public override BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
                throw new Exception("请扫描或输入待销毁的条码标签");
            using (TransactionScope ts = new TransactionScope())
            {

                ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                StringBuilder sb = new StringBuilder();
                foreach (string item in Barcodes)
                {
                    sb.Append(",'" + item + "'");
                }
                sb.Remove(0, 1);

                string sql = @"
            declare @RC int
            declare @result nvarchar(200)
            declare @dj varchar(30)
            set @RC=0
            set @result=N'YES'

            if @result='YES'
            begin

            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02011)
            select RW01001,getdate(),@userid,@username,@Remark from RW01 where RW01001 IN ([BIDS])

            update RW01 set RW01024=@userid,RW01025=@username,RW01032=5 where RW01001 IN ([BIDS])
            end
            select @result MSG
            ";
                sql = sql.Replace("[BIDS]", sb.ToString());
                DataSet ds = adoRW.GetDataSet(sql, new SqlParameter("@Remark", this.Remark), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName));
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string msg = ds.Tables[0].Rows[0][0] + "";
                    if (msg != "YES")
                        throw new Exception(msg);
                    else if (this.isExportFile)
                    {
                        this.ExportXML(sb.ToString());
                    }
                }
                ts.Complete();
                return this;
            }
        }
Beispiel #12
0
        public override BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
                throw new Exception("请扫描或输入待入库的条码标签");
            using (TransactionScope ts = new TransactionScope())
            {

                ModelAdo<FGBarcodeModel> adoRW = new ModelAdo<FGBarcodeModel>();
                StringBuilder sb = new StringBuilder();
                foreach (string item in Barcodes)
                {
                    sb.Append(",'" + item + "'");
                }
                sb.Remove(0, 1);

                string sql = @"
            declare @RC int
            declare @result nvarchar(200)
            declare @dj varchar(30)
            set @RC=0
            set @result=N'YES'

            if @result='YES'
            begin
            exec PROC_GETID 'FG03',@dj output

            insert into FG02(FG02002,FG02003,FG02004,FG02005,FG02010,FG02011)
            select FG01001,getdate(),@userid,@username,@dj,N'装箱到'+@PackingID from FG01 where FG01001 IN ([BIDS])

            update FG01 set FG01024=@userid,FG01025=@username,FG01031=@PackingID where FG01001 IN ([BIDS])
            update FG07 set FG07008=@Status where FG07001 =@PackingID
            end
            select @result MSG
            ";
                sql = sql.Replace("[BIDS]", sb.ToString());
                DataSet ds = adoRW.GetDataSet(sql, new SqlParameter("@PackingID", this.PackingID), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@Status", this.Status));
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string msg = ds.Tables[0].Rows[0][0] + "";
                    if (msg != "YES")
                        throw new Exception(msg);
                }
                ts.Complete();
                return this;
            }
        }
Beispiel #13
0
 /// <summary>
 /// 通过录入数据,获取提示PO订单号码
 /// </summary>
 /// <returns></returns>
 public override BaseSearchModel GetModelByID(string id)
 {
     ModelAdo<WOLineModel> modelAdo = new ModelAdo<WOLineModel>();
     List<string> pos = new List<string>();
     string strSql = "select top  10  T.MP64001 as WO   from (select distinct(MP64001) from view_WO where  charindex(@tips,MP64001)>0 ) T";
     DataSet ds = modelAdo.GetDataSet(strSql, new SqlParameter("@tips", id));
     if (ds != null && ds.Tables[0].Rows.Count > 0)
     {
         string[] rs = new string[ds.Tables[0].Rows.Count];
         for (int i = 0; i < rs.Length; i++)
         {
             rs[i] = ds.Tables[0].Rows[i][0] + "";
         }
         this.WOS = rs;
     }
     return this;
 }
Beispiel #14
0
 /// <summary>
 ///  通过录入数据,获取提示PO订单号码
 /// </summary>
 /// <returns></returns>
 public override BarcodeModel.MODEL.BaseSearchModel Insert()
 {
     ModelAdo<POLineModel> modelAdo = new ModelAdo<POLineModel>();
     List<string> pos = new List<string>();
     string strSql = "select top  10  T.PC01001 as PO   from (select distinct(PC01001) from view_poline where Company=@company and  charindex(@tips,PC01001)>0) T";
     DataSet ds = modelAdo.GetDataSet(strSql, new SqlParameter("@company", company), new SqlParameter("@tips", tips));
     if (ds != null && ds.Tables[0].Rows.Count > 0)
     {
         string[] rs = new string[ds.Tables[0].Rows.Count];
         for (int i = 0; i < rs.Length; i++)
         {
             rs[i] = ds.Tables[0].Rows[i][0] + "";
         }
         this.POS = rs;
     }
     return this;
 }
Beispiel #15
0
 public override void OnLoad(HttpContext context)
 {
     base.OnLoad(context);
     requestBody             = new RequestBody();
     requestBody.accessToken = context.Request["accessToken"];
     if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0)
     {
         SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
     }
     else
     {
         //验证用户
         TokenHelper    token          = new TokenHelper();
         UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
         if (userTokenModel == null)
         {
             SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
         }
         else
         {
             ModelAdo <UserModel> userModel = new ModelAdo <UserModel>();
             List <UserModel>     models    = userModel.GetList(" id NOT IN (?id) AND status != 1", "", "",
                                                                new MySqlParameter("?id", userTokenModel.uid));
             if (models != null)
             {
                 List <Friend> Friends = new List <Friend>();
                 foreach (UserModel model in models)
                 {
                     Friend friend = new Friend();
                     friend.id     = model.id;
                     friend.name   = model.name;
                     friend.avatar = model.avatar;
                     Friends.Add(friend);
                 }
                 responseBody         = new ResponseBody();
                 responseBody.Friends = Friends;
                 responseJson         = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
             }
             else
             {
                 SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
             }
         }
     }
 }
Beispiel #16
0
        /// <summary>
        /// token 信息,修改token详细信息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public int updateToken(UserTokenModel model)
        {
            int obj = 0;

            userTokenModel = new ModelAdo <Model.UserTokenModel>();
            UserTokenModel token = userTokenModel.GetModel(" uid =?uid ", "", new MySqlParameter("?uid", model.uid));

            if (token != null)
            {
                model.id = token.id;
                obj      = userTokenModel.Update(model);
            }
            else
            {
                obj = userTokenModel.Insert(model);
            }
            return(obj);
        }
Beispiel #17
0
        public override BaseSearchModel Insert()
        {
            ModelAdo<UserModel> adoUser = new ModelAdo<UserModel>();
            userModel = adoUser.GetModel("UR01003=@loginName and UR01004=@pass", "", new SqlParameter("@loginName", this.LoginName), new SqlParameter("@pass", this.Password));
            if (userModel != null)
            {

                ModelAdo<LoginHistoryModel> adoLH = new ModelAdo<LoginHistoryModel>();
                loginHistoryModel = adoLH.GetModel("UR05002=@id and UR05005=1", "*", new SqlParameter("@id", userModel.ID));
                if (loginHistoryModel != null)
                {
                    this.ErrorMsg = string.Format("用户{0}已在其他{1}终端登录,请先退出", userModel.UserName, loginHistoryModel.LoginType);
                    this.LoginSuccess = false;
                }
                else
                {
                    string id = Guid.NewGuid().ToString();
                    loginHistoryModel = new LoginHistoryModel()
                    {
                        ID = id,
                        LoginTime = DateTime.Now,
                        LogoutTime = DateTime.Now,
                        ComputerName = this.ComputerName,
                        IP = this.IP,
                        LoginStatus = 1,
                        LoginType = this.LoginType,
                        UserID = userModel.ID
                    };
                    int result = adoLH.Insert(loginHistoryModel);
                    if (result == 1)
                    {
                        this.Token = id;
                        this.UserID = userModel.ID;
                        this.LoginSuccess = true;
                    }
                }
            }
            else
            {
                this.LoginSuccess = false;
                this.ErrorMsg = "用户名或密码不正确";
            }
            return this;
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody          = new RequestBody();
            requestBody.userName = context.Request["userName"];
            requestBody.userPwd  = context.Request["userPwd"];
            requestBody.userType = context.Request["userType"];
            if (requestBody.userName == null || requestBody.userPwd == null || requestBody.userType == null)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                string password = StringHelper.StringToMD5(requestBody.userPwd);

                ModelAdo <UserModel> userModel = new ModelAdo <UserModel>();
                UserModel            model     = userModel.GetModel(" rid=?rid and name =?name", "",
                                                                    new MySqlParameter("?rid", requestBody.userType),
                                                                    new MySqlParameter("?name", requestBody.userName));
                if (model != null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXIST, out statusCode, out responseJson);
                }
                else
                {
                    UserModel token = new UserModel();
                    token.rid      = Convert.ToInt32(requestBody.userType);
                    token.name     = requestBody.userName;
                    token.password = password;
                    token.ctime    = StringHelper.ConvertDateTimeInt(DateTime.Now);
                    if (userModel.Insert(token) >= 1)
                    {
                        responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_REGISTER_ERROR, out statusCode, out responseJson);
                    }
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// 依据扫描条码,是否能够进行
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public override BaseSearchModel GetModelByID(string id)
        {
            if (RecevieID == null || RecevieID.Length == 0)
            {
                throw new Exception("请扫描或输入领料单的条码标签");
            }
            else {
                ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                RWBarcodeModel RWModel = adoRW.GetModelByID(Barcode, "*");
                if (RWModel == null)
                {
                    throw new Exception("领料条码标签不存在");
                }
                else
                {
                    //依据扫描原材料条码,获取对应的数据

                }
            }

            return base.GetModelByID(id);
        }
        public void ProcessRequest(HttpContext context)
        {
            int status = 0;
            ModelAdo <OrderTypeModel> orderTypeModel = new ModelAdo <OrderTypeModel>();
            List <OrderTypeModel>     list           = orderTypeModel.GetList("status = ?status", " sort desc", "", new MySqlParameter("?status", status));


            if (list.Count == 0)
            {
                status = 0;
                msg    = "未能找到数据集合!";
                goto returnJson;
            }
            else
            {
                output = from model in list
                         select new
                {
                    id     = model.id,
                    pid    = model.pid,
                    name   = model.name,
                    remark = model.remark,
                };
            }

returnJson:
            Dictionary <string, object> returnJson = new Dictionary <string, object>
            {
                { "status", status },
                { "msg", msg },
                { "output", output }
            };
            string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented);

            context.Response.ContentType = "application/json";
            context.Response.Write(json);
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.oid         = context.Request["oid"];
            requestBody.action      = Convert.ToInt32(context.Request["action"]);
            if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid.Length == 0 || requestBody.action == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token          = new TokenHelper();
                UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
                if (userTokenModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    #region 客服取消供应商抢单数据、修改订单状态回派单中
                    if (requestBody.action == 2)
                    {
                        //获取当前订单信息
                        ModelAdo <OrderModel> modelAdo = new ModelAdo <OrderModel>();
                        OrderModel            order    = modelAdo.GetModel("id=?oid AND ostatus=?ostatus", "",
                                                                           new MySqlParameter("?oid", requestBody.oid),
                                                                           new MySqlParameter("?ostatus", 3));
                        if (order != null)
                        {
                            //获取派单供应商对应订单中间表数据
                            ModelAdo <OrderUserModel> ouModelAdo = new ModelAdo <OrderUserModel>();
                            OrderUserModel            orderUser  = ouModelAdo.GetModel("oid=?oid AND uid=?uid", "",
                                                                                       new MySqlParameter("?oid", requestBody.oid),
                                                                                       new MySqlParameter("?uid", order.sendUid));
                            orderUser.amount     = 0;
                            orderUser.remark     = "被供应商退回抢单数据";
                            orderUser.createTime = 0;
                            orderUser.status     = 1;
                            if (ouModelAdo.Update(orderUser) >= 1)
                            {
                                order.ostatus    = 2;
                                order.sendUid    = 0;
                                order.sendTime   = 0;
                                order.sendRemark = "被供应商退回抢单数据";
                                order.sendAmount = 0;
                                if (modelAdo.Update(order) >= 1)
                                {
                                    SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                }
                                else
                                {
                                    SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                                }
                            }
                        }
                        else
                        {
                            SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                        }
                    }
                    #endregion

                    #region 客服确认供应商抢单数据
                    else if (requestBody.action == 4)
                    {
                        //获取当前订单信息
                        ModelAdo <OrderModel> modelAdo = new ModelAdo <OrderModel>();
                        OrderModel            order    = modelAdo.GetModel("id=?oid AND ostatus=?ostatus", "",
                                                                           new MySqlParameter("?oid", requestBody.oid),
                                                                           new MySqlParameter("?ostatus", 3));
                        order.ostatus    = 4;
                        order.sendRemark = "客服确认供应商抢单数据";
                        if (order != null)
                        {
                            if (modelAdo.Update(order) >= 1)
                            {
                                //删除派单供应商对应订单中间表数据
                                ModelAdo <OrderUserModel> ouModelAdo = new ModelAdo <OrderUserModel>();
                                int delCount = ouModelAdo.ExecuteSql("DELETE FROM ct_order_user WHERE oid=?oid",
                                                                     new MySqlParameter("?oid", requestBody.oid));
                                if (delCount >= 1)
                                {
                                    SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                }
                                else
                                {
                                    SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                                }
                            }
                        }
                        else
                        {
                            SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                        }
                    }
                    #endregion

                    #region 客服确认关闭已确认数据
                    else if (requestBody.action == 5)
                    {
                        //获取当前订单信息
                        ModelAdo <OrderModel> closeModelAdo = new ModelAdo <OrderModel>();
                        OrderModel            closeOrder    = closeModelAdo.GetModel("id=?oid AND ostatus=?ostatus", "",
                                                                                     new MySqlParameter("?oid", requestBody.oid),
                                                                                     new MySqlParameter("?ostatus", 4));
                        closeOrder.ostatus    = 5;
                        closeOrder.sendRemark = "客服确认完成订单数据";
                        if (closeOrder != null)
                        {
                            if (closeModelAdo.Update(closeOrder) >= 1)
                            {
                                SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);

                                //删除派单供应商对应订单中间表数据
                                ModelAdo <OrderUserModel> ouModelAdo = new ModelAdo <OrderUserModel>();
                                int delCount = ouModelAdo.ExecuteSql("DELETE FROM ct_order_user WHERE oid=?oid",
                                                                     new MySqlParameter("?oid", requestBody.oid));
                                //if (delCount >= 1)
                                //{
                                //}
                                //else
                                //{
                                //}
                            }
                            else
                            {
                                SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                            }
                        }
                        else
                        {
                            SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                        }
                    }
                    #endregion

                    #region 其他
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
                    }
                    #endregion
                }
            }
        }
Beispiel #22
0
        public override BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
                throw new Exception("请扫描或输入待入库的条码标签");
            ModelAdo<LocationModel> adoLoc = new ModelAdo<LocationModel>();
            List<LocationModel> lm = adoLoc.GetList("SC36001=@wh and SC36002=@bin", "", "", new SqlParameter("@wh", this.Warehouse), new SqlParameter("@bin", this.Bin));

            if (lm.Count == 0)
                throw new Exception("仓库或库位不存在");
            using (TransactionScope ts = new TransactionScope())
            {

                ModelAdo<FGBarcodeModel> adoRW = new ModelAdo<FGBarcodeModel>();
                StringBuilder sb = new StringBuilder();
                foreach (string item in Barcodes)
                {
                    sb.Append(",'" + item + "'");
                }
                sb.Remove(0, 1);

                string sql = @"
            declare @RC int
            declare @result nvarchar(200)
            declare @dj varchar(30)
            set @RC=0
            set @result=N'YES'
            select @RC=count(FG01001) from FG01 where FG01001 IN ([BIDS]) and FG01032>1
            if @RC>0
            begin
            set @result=N'不能对已入库的料进行入库操作'
            end
            set @RC=0
            select @RC=count(distinct(FG01033)) from FG01 where FG01001 IN ([BIDS])
            if @RC>1
            begin
            set @result=N'请对同一工单号进行入库操作'
            end
            if @result='YES'
            begin
            exec PROC_GETID 'FG03',@dj output

            insert into FG03(FG03001,FG03002,FG03003,FG03004,FG03005,FG03006,FG03007,FG03008)
            values(@dj,getdate(),@userid,@username,'','','',@Remark)

            insert into FG02(FG02002,FG02003,FG02004,FG02005,FG02010,FG02011)
            select FG01001,getdate(),@userid,@username,@dj,N'入库到'+@whstr from FG01 where FG01001 IN ([BIDS])

            insert into FG04(FG04002,FG04003,FG04004,FG04005)
            select getdate(),@dj,FG01001,N'入库到'+@whstr from FG01 where FG01001 IN ([BIDS])

            update FG01 set FG01008=@wh,FG01009=@sh,FG01010=getdate(),FG01024=@userid,FG01025=@username,FG01027=@dj,FG01032=2 where FG01001 IN ([BIDS])
            end
            select @result MSG
            ";
                sql = sql.Replace("[BIDS]", sb.ToString());
                DataSet ds = adoRW.GetDataSet(sql, new SqlParameter("@Remark", this.Remark), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName),
                    new SqlParameter("@wh", this.Warehouse), new SqlParameter("@sh", this.Bin), new SqlParameter("@whstr", this.Warehouse + "[" + this.Bin + "]"));
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string msg = ds.Tables[0].Rows[0][0] + "";
                    if (msg != "YES")
                        throw new Exception(msg);
                    else
                    {
                        this.ExportXML(sb.ToString());
                    }
                }
                ts.Complete();
                return this;
            }
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.uTo         = Convert.ToInt32(context.Request["to"]);
            requestBody.content     = context.Request["content"];

            if (requestBody.content.Length == 0 || requestBody.accessToken.Trim().Length == 0 || requestBody.uTo == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token     = new TokenHelper();
                UserTokenModel fromModel = token.getUserToken(requestBody.accessToken);
                UserTokenModel toModel   = token.getUserToken(requestBody.uTo);
                if (fromModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    int msgstatus = 0;

                    #region 入库至本地
                    ModelAdo <MsgModel> modelAdo = new ModelAdo <MsgModel>();
                    MsgModel            msg      = new MsgModel();
                    msg.ufrom      = Convert.ToInt32(fromModel.uid);
                    msg.uto        = requestBody.uTo;
                    msg.content    = requestBody.content;
                    msg.createTime = StringHelper.ConvertDateTimeInt(DateTime.Now);
                    msg.status     = msgstatus;
                    if (modelAdo.Insert(msg) >= 1)
                    {
                        #region 百度推送
                        if (toModel != null && toModel.bpuserId.Length >= 1 && toModel.channelId.Length >= 1)
                        {
                            //获取插入本地数据
                            MsgModel msgPush = modelAdo.GetModel("ufrom=?ufrom AND uto=?uto AND createTime=?createTime AND status=0", "",
                                                                 new MySqlParameter("?ufrom", msg.ufrom),
                                                                 new MySqlParameter("?uto", msg.uto),
                                                                 new MySqlParameter("?createTime", msg.createTime));
                            if (msgPush != null)
                            {
                                try
                                {
                                    //百度配置信息
                                    string secretKey    = ConfigurationManager.AppSettings["baidu_secret_key"];
                                    string apiKey       = ConfigurationManager.AppSettings["baidu_api_key"];
                                    uint   depolyStatus = uint.Parse(ConfigurationManager.AppSettings["baidu_depoly_status"]);

                                    String    messages     = "";
                                    TimeSpan  ts           = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
                                    uint      unixTime     = (uint)ts.TotalSeconds;
                                    string    messageksy   = "api";
                                    uint      message_type = 1;
                                    BaiduPush Bpush        = new BaiduPush("POST", secretKey);



                                    if (toModel.deviceType == 1)
                                    {
                                        message_type       = 1;
                                        toModel.deviceType = 4;
                                        IOSNotification notifaction = new IOSNotification();
                                        notifaction.id         = msgPush.id;
                                        notifaction.ufrom      = msgPush.ufrom;
                                        notifaction.uto        = msgPush.uto;
                                        notifaction.content    = msgPush.content.Trim();
                                        notifaction.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", System.DateTime.Now);
                                        notifaction.type       = msgPush.type;
                                        notifaction.status     = 1;
                                        IOSAPS aps = new IOSAPS()
                                        {
                                            alert = "收到一条新消息",
                                        };
                                        notifaction.aps = aps;
                                        messages        = notifaction.getJsonString();
                                    }
                                    else
                                    {
                                        message_type       = 0;
                                        toModel.deviceType = 3;
                                        BaiduPushNotification notifaction = new BaiduPushNotification();
                                        notifaction.title = "";
                                        //构建custom_content信息
                                        BaiduDescription bdMsg = new BaiduDescription();
                                        bdMsg.id                   = msgPush.id;
                                        bdMsg.ufrom                = msgPush.ufrom;
                                        bdMsg.uto                  = msgPush.uto;
                                        bdMsg.content              = msgPush.content;
                                        bdMsg.createTime           = string.Format("{0:yyyy/MM/dd HH:mm:ss}", System.DateTime.Now);
                                        bdMsg.type                 = msgPush.type;
                                        bdMsg.status               = 1;
                                        notifaction.description    = "收到一条新消息";
                                        notifaction.custom_content = bdMsg;
                                        messages                   = notifaction.getJsonString();
                                    }



                                    PushOptions pOpts = new PushOptions("push_msg", apiKey, toModel.bpuserId.ToString(),
                                                                        toModel.channelId.ToString(), Convert.ToUInt32(toModel.deviceType), messages, messageksy, unixTime);
                                    pOpts.message_type  = message_type;
                                    pOpts.deploy_status = depolyStatus;
                                    pOpts.push_type     = 1;
                                    string response = Bpush.PushMessage(pOpts);
                                    responseJson = response;
                                    msgstatus    = 1;

                                    //处理数据为已读
                                    if (msg.status == 0)
                                    {
                                        msgPush.status = 1;
                                        modelAdo.Update(msgPush);
                                    }

                                    //SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                    //responseJson = strBDMsg;
                                }
                                catch (Exception ex)
                                {
                                    responseJson = ex.ToString();
                                    SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                        }
                        #endregion
                    }
                }
            }
        }
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            lock (objLock)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    BaseAdo ba = new BaseAdo();
                    BaseAdo bascala = new BaseAdo() { ConnectionStr = SysConfig.DBScalaConnection };
                    string sqlpo = @"
            select * from view_poline where PC01001=@po and SC01003=@stockspec and Company=@company
            select * from view_Stock where SC01003=@stockspec and Company=@company
            ";
                    string sql = @"
            insert into RW13(RW13002,RW13003,RW13004,RW13005,RW13006,RW13007,RW13008,RW13009,RW13010,RW13011,RW13012,RW13013,RW13014,RW13015,RW13016,RW13017,RW13018,RW13019,RW13020,RW13021,RW13022)
            values(getdate(),@IMPNO,@userid,@po,@poline,@stockcode,@stockname,@stockspec,@lpn,@supplierbatch,@productdate,@exdate,@qty,@unit,@company,@boxid,@supcode,@supname,@pounit,@saleunit,@stocktype)";

                    string strImport = System.Text.Encoding.ASCII.GetString(this.Bytes);
                    string[] strImportLine = strImport.Replace("\r", " ").Split('\n');
                    IMPNO = Guid.NewGuid().ToString();
                    for (int i = 1; i < strImportLine.Length; i++)
                    {
                        string BarcodeId = "";//导入文件中获取
                        string PackageId = "";//导入文件中获取
                        string StockCode = "";
                        string StockName = "";
                        string StockSpec = "";//导入文件中获取
                        string StockUnit = "";//导入文件中获取
                        string PO = "";//导入文件中获取
                        decimal StockUnitQty = 0;//导入文件中获取
                        string Company = "";//导入文件中获取
                        string SupplierBatch = "";//导入文件中获取
                        string supplierCode = "";
                        string supplierName = "";
                        double purunit = 1;
                        double saleunit = 1;
                        string stockType = "02";
                        string poline = "";
                        DateTime ProductionTime = DateTime.Now;//导入文件中获取
                        DateTime ValidityTime = DateTime.Now;//导入文件中获取

                        string[] strImprotLineItem = strImportLine[i].Split(';');
                        switch (strImprotLineItem[0])
                        {
                            case "11117": Company = "31"; break;
                            case "11116": Company = "32"; break;
                            default: Company = "-"; break;
                        }
                        PO = strImprotLineItem[2];
                        StockSpec = strImprotLineItem[3];
                        PackageId = strImprotLineItem[5];
                        BarcodeId = strImprotLineItem[6];
                        SupplierBatch = strImprotLineItem[7];
                        StockUnitQty = decimal.Parse(strImprotLineItem[10]);
                        DateTime.TryParse(strImprotLineItem[15], out ProductionTime);
                        DateTime.TryParse(strImprotLineItem[16], out ValidityTime);

                        DataSet ds = bascala.GetDataSet(sqlpo, new SqlParameter("@Company", Company), new SqlParameter("@stockspec", StockSpec), new SqlParameter("@po", PO));
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            poline = ds.Tables[0].Rows[0]["PC03002"] + "";
                            supplierCode = ds.Tables[0].Rows[0]["PL01001"] + "";
                            supplierName = ds.Tables[0].Rows[0]["PL01002"] + "";
                        }
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            double.TryParse(ds.Tables[1].Rows[0]["SC01072"] + "", out purunit);
                            double.TryParse(ds.Tables[1].Rows[0]["SC01073"] + "", out saleunit);
                            stockType = ds.Tables[1].Rows[0]["SC01035"] + "";
                            StockCode = ds.Tables[1].Rows[0]["SC01001"] + "";
                            StockName = ds.Tables[1].Rows[0]["SC01002"] + "";
                            StockUnit = ds.Tables[1].Rows[0]["UNIT"] + "";
                        }
                        ba.ExecuteSql(sql, new SqlParameter("@IMPNO", IMPNO),
                            new SqlParameter("@userid", this.LoginUserID),
                            new SqlParameter("@po", PO),
                            new SqlParameter("@poline", poline),
                            new SqlParameter("@stockcode", StockCode),
                            new SqlParameter("@stockname", StockName),
                            new SqlParameter("@stockspec", StockSpec),
                            new SqlParameter("@lpn", BarcodeId),
                            new SqlParameter("@supplierbatch", SupplierBatch),
                            new SqlParameter("@productdate", ProductionTime),
                            new SqlParameter("@exdate", ValidityTime),
                            new SqlParameter("@qty", StockUnitQty),
                            new SqlParameter("@unit", StockUnit),
                            new SqlParameter("@company", Company),
                            new SqlParameter("@boxid", PackageId),
                            new SqlParameter("@supcode", supplierCode),
                            new SqlParameter("@supname", supplierName),
                            new SqlParameter("@pounit", purunit),
                            new SqlParameter("@saleunit", saleunit),
                            new SqlParameter("@stocktype", stockType));

                    }
                    ModelAdo<USBarcodeModel> adoUB = new ModelAdo<USBarcodeModel>();
                    this.ReturnUSBarcodes = adoUB.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO));
                    ModelAdo<USBarcodeGroup> adoUBG = new ModelAdo<USBarcodeGroup>();
                    this.ReturnUSBarcodeGroups = adoUBG.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO));
                    ts.Complete();

                }
            }
            return this;
        }
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            //①:解析获取的文件数据,依据每行来读取。
            //②:替换对应公司,17-31,16-32[[不存在回滚]]
            //③:替换PART_CODE,通过SC01003,找到对应的StockName,StockCode[不存在回滚]
            //④:条码编号:[存在回滚]
            //⑤:是否存在装箱号条码。有:判断装箱条码中是否存在,如果存在:直接并入该装箱号条码。如果不存在:新建
            //⑥:插入原材料:   1:插入,父单据号表;
            //                   2:插入,子单据号明细表;
            //                   3:插入,原材料条码表;
            //                   4:插入,条码历史记录表;

            lock (objLock)
            {

                using (TransactionScope ts = new TransactionScope())
                {
                    try
                    {

                        BaseAdo ba = new BaseAdo();
                        string sql = @"
            declare @billid varchar(30)
            exec PROC_GETID 'RW03',@billid output
            --单据头
            insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008)
            values(@billid,getdate(),@userid,@username,'','','',N'创建条码')
            select @billid t";
                        DataSet dsBillId = ba.GetDataSet(sql, new SqlParameter("@userid", this.LoginUserID),
                                new SqlParameter("@username", this.LoginUserName));
                        string BillId = ""; //总单据号
                        if (dsBillId != null && dsBillId.Tables[0].Rows.Count > 0)
                        {
                            BillId = dsBillId.Tables[0].Rows[0][0] + "";
                        }

                        string strImport = System.Text.Encoding.ASCII.GetString(this.Bytes);
                        string[] strImportLine = strImport.Replace("\r", " ").Split('\n');
                        for (int i = 1; i < strImportLine.Length; i++)
                        {

                            string BarcodeId = "";//导入文件中获取
                            string PackageId = "";//导入文件中获取
                            string StockCode = "";
                            string StockName = "";
                            string StockSpec = "";//导入文件中获取
                            string StockUnit = "";//导入文件中获取
                            string PO = "";//导入文件中获取
                            decimal StockUnitQty = 0;//导入文件中获取
                            string Company = "";//导入文件中获取
                            string SupplierBatch = "";//导入文件中获取
                            DateTime ProductionTime = DateTime.Now;//导入文件中获取
                            DateTime ValidityTime = DateTime.Now;//导入文件中获取

                            string[] strImprotLineItem = strImportLine[i].Split(';');
                            if (strImprotLineItem[0].Contains("17"))
                            {
                                Company = "31";
                            }
                            else if (strImprotLineItem[0].Contains("16"))
                            {
                                Company = "32";
                            }
                            else
                            {
                                throw new Exception("未找到相对应的公司信息!");
                            }
                            PO = strImprotLineItem[2];
                            StockSpec = strImprotLineItem[3];
                            PackageId = strImprotLineItem[5];
                            BarcodeId = strImprotLineItem[6];
                            SupplierBatch = strImprotLineItem[7];
                            StockUnitQty = decimal.Parse(strImprotLineItem[10]);
                            DateTime.TryParse(strImprotLineItem[15], out ProductionTime);
                            DateTime.TryParse(strImprotLineItem[16], out ValidityTime);

                            ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>();
                            RWBarcodeModel rwModel = adoBarcode.GetModelByID(BarcodeId);
                            if (rwModel != null && rwModel.ID.Length >= 1)
                            {
                                throw new Exception(BarcodeId + "已存在于条码系统中!");
                            }
                            if (!string.IsNullOrEmpty(PackageId))
                            {
                                ModelAdo<PackingModel> adoPackage = new ModelAdo<PackingModel>();
                                PackingModel packageModel = adoPackage.GetModelByID(PackageId);
                                if (packageModel != null)
                                {

                                }
                                else
                                {
                                    string sqlPackage = @"
            --装箱单
            insert into RW07(RW07001,RW07002,RW07003,RW07004,RW07005,RW07006,RW07007,RW07008)
            values(@packageid,getdate(),@userid,@username,0,'',0,2)";
                                    ba.ExecuteSql(sqlPackage, new SqlParameter("packageid", PackageId),
                                            new SqlParameter("@userid", this.LoginUserID),
                                            new SqlParameter("@username", this.LoginUserName));
                                }
                            }

                            ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>();
                            List<StockModel> Stocks = adoStock.GetList("SC01003=@stockspec", "", "", new SqlParameter("@stockspec", StockSpec));
                            if (Stocks != null && Stocks.Count >= 1)
                            {
                                StockCode = Stocks[0].StockCode;
                                StockName = Stocks[0].StockName;
                                StockUnit = Stocks[0].Unit;
                                StockUnitQty = Stocks[0].UQTY;
                            }
                            else
                            {
                                //throw new Exception("未找到相对应的物料信息!");
                                continue;
                            }

                            string barcodeSql = @"
            --单据明细
            insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@billid,@barcodeid,N'创建条码')
            --历史记录
            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            values(@barcodeid,getdate(),@userid,@username,@billid,N'创建条码标签')
            --原材料
            insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01014,RW01024,RW01025,RW01027,RW01031,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043)
            values(@barcodeid,@stock,@stockname,@stockspec,@unit,@qty,@po,@userid,@username,@billid,@packageid,1,@company,@supplierbatch,@productiontime ,@validitytime,@tqty,@stype,'PO')
            ";

                            ba.ExecuteSql(barcodeSql, new SqlParameter("@userid", this.LoginUserID),
                                new SqlParameter("@username", this.LoginUserName),
                                new SqlParameter("@stock", StockCode),
                                new SqlParameter("@stockname", StockName),
                                new SqlParameter("@barcodeid", BarcodeId),
                                new SqlParameter("@stockspec", StockSpec),
                                new SqlParameter("@packageid", PackageId),
                                new SqlParameter("@unit", StockUnit),
                                new SqlParameter("@qty", StockUnitQty),
                                new SqlParameter("@tqty", Stocks[0].UQTY),
                                new SqlParameter("@po", PO),
                                new SqlParameter("@stype", Stocks[0].StockType),
                                new SqlParameter("@company", Company),
                                new SqlParameter("@supplierbatch", SupplierBatch),
                                new SqlParameter("@productiontime", ProductionTime),
                                new SqlParameter("@validitytime", ValidityTime),
                                new SqlParameter("@billid", BillId));
                        }
                        ts.Complete();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return this;
        }
Beispiel #26
0
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            string sql = @"
            declare @bid varchar(30)
            declare @hid int
            declare @i int

            set @i=0
            while @i<@printcount
            begin
            exec PROC_GETID 'RW01',@bid output
            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签')

            insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01033,RW01018,RW01024,RW01025,RW01027,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01042,RW01043)
            values(@bid,@stock,@stockname,@stockspec,@unit,@qty,@wo,@remark,@userid,@username,@dj,1,@company,@Batch,@ProductionTime ,@ValidityTime,@tqty,@type,@pagecode,'WO')

            insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@dj,@bid,N'创建条码')

            set @i=@i+1
            end
            ";
            ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>();
            StockModel sm = adoStock.GetModelByID(this.StockCode);
            BaseAdo ba = new BaseAdo();
            ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID),
                new SqlParameter("@username", this.LoginUserName),
                new SqlParameter("@stock", this.StockCode),
                new SqlParameter("@stockname", this.StockName),
                new SqlParameter("@stockspec", this.StockSpec),
                new SqlParameter("@unit", this.Unit),
                new SqlParameter("@qty", this.UnitQty),
                new SqlParameter("@tqty", sm.StockType == "02" ? 1 : sm.UQTY),
                new SqlParameter("@type", sm.StockType),
                new SqlParameter("@wo", this.WorkOrder),
                new SqlParameter("@remark", this.Remark),
                new SqlParameter("@company", this.Company),
                new SqlParameter("@printcount", this.BarcodeQty),
                new SqlParameter("@Batch", this.Batch),
                new SqlParameter("@ProductionTime", this.ProductDate),
                new SqlParameter("@ValidityTime", this.LifeDate),
                new SqlParameter("@pagecode", this.PageCode),
                new SqlParameter("@dj", this.Danju));
            return this;

            /*
            string sql = @"
            declare @dj varchar(30)
            exec PROC_GETID 'FG03',@dj output

            declare @bid varchar(30)
            declare @hid int
            declare @i int

            insert into FG03(FG03001,FG03002,FG03003,FG03004,FG03005,FG03006,FG03007,FG03008)
            values(@dj,getdate(),@userid,@username,'','','',N'创建条码')

            set @i=0
            while @i<@printcount
            begin
            exec PROC_GETID 'FG01',@bid output
            insert into FG02(FG02002,FG02003,FG02004,FG02005,FG02010,FG02011)
            values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签')

            insert into FG01(FG01001,FG01002,FG01003,FG01004,FG01005,FG01006,FG01012,FG01013,FG01014,FG01015,FG01018,FG01024,FG01025,FG01027,FG01032,FG01037,FG01033,FG01034,FG01035,FG01036,FG01038)
            values(@bid,@stock,@stockname,@stockspec,@unit,@qty,'','','','',@remark,@userid,@username,@dj,1,@company,@workorder,@productdate,@lifedate,@pagecode,@lifeday)

            insert into FG04(FG04002,FG04003,FG04004,FG04005) values(getdate(),@dj,@bid,N'创建条码')

            set @i=@i+1
            end
            ";
            BaseAdo ba = new BaseAdo();
            ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID),
                new SqlParameter("@username", this.LoginUserName),
                new SqlParameter("@workorder", this.WorkOrder),
                new SqlParameter("@stock", this.StockCode),
                new SqlParameter("@stockname", this.StockName),
                new SqlParameter("@stockspec", this.StockSpec),
                new SqlParameter("@unit", this.Unit),
                new SqlParameter("@qty", this.UnitQty),
                new SqlParameter("@remark", this.Remark),
                new SqlParameter("@company", this.Company),
                new SqlParameter("@printcount", this.BarcodeQty),
                new SqlParameter("@productdate", this.ProductDate.ToString("yyyy-MM-dd")),
                new SqlParameter("@lifedate", this.ProductDate.AddDays(this.LifeDate).ToString("yyyy-MM-dd")),
                new SqlParameter("@lifeday", this.LifeDate),
                new SqlParameter("@pagecode", this.PageCode));
            return this;
             * */
        }
Beispiel #27
0
        public override List<BaseSearchModel> GetALL(bool enableSearch = false)
        {
            ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>();
            List<SqlParameter> listParam = new List<SqlParameter>();
            StringBuilder sbWhere = new StringBuilder();
            sbWhere.Append(" 1=1 ");
            if (!BeginTimeInWH.Equals(DateTime.MinValue) && !EndTimeInWH.Equals(DateTime.MinValue))
            {
                sbWhere.Append(" AND RW01010 BETWEEN  @BeginTimeInWH AND @EndTimeInWH ");
                listParam.Add(new SqlParameter("@BeginTimeInWH", BeginTimeInWH));
                listParam.Add(new SqlParameter("@EndTimeInWH", EndTimeInWH));

            }
            if (!BeginTimeOutWH.Equals(DateTime.MinValue) && !EndTimeOutWH.Equals(DateTime.MinValue))
            {
                sbWhere.Append(" AND RW01011 BETWEEN  @BeginTimeOutWH AND @EndTimeOutWH ");
                listParam.Add(new SqlParameter("@BeginTimeOutWH", BeginTimeOutWH));
                listParam.Add(new SqlParameter("@EndTimeOutWH", EndTimeOutWH));

            }
            if (!String.IsNullOrEmpty(this.ID))
            {
                sbWhere.Append(" AND RW01001 = @ID");
                listParam.Add(new SqlParameter("@ID", ID));
            }
            if (!String.IsNullOrEmpty(this.StockCode))
            {
                sbWhere.Append(" AND RW01002 = @StockCode");
                listParam.Add(new SqlParameter("@StockCode", StockCode));
            }
            if (!String.IsNullOrEmpty(this.StockName))
            {
                sbWhere.Append(" AND RW01003 = @StockName");
                listParam.Add(new SqlParameter("@StockName", StockName));
            }
            if (!String.IsNullOrEmpty(this.BoxID))
            {
                sbWhere.Append(" AND RW01031 = @BoxID ");
                listParam.Add(new SqlParameter("@BoxID", this.BoxID));
            }
            if (!String.IsNullOrEmpty(this.SupplierBatch))
            {
                sbWhere.Append(" AND RW01035 = @SupplierBatch ");
                listParam.Add(new SqlParameter("@SupplierBatch", this.SupplierBatch));
            }
            if (!String.IsNullOrEmpty(this.BatchID))
            {
                sbWhere.Append(" AND RW01036 = @BatchID ");
                listParam.Add(new SqlParameter("@BatchID", this.BatchID));
            }
            if (!String.IsNullOrEmpty(this.PO))
            {
                sbWhere.Append(" AND RW01014 = @PO ");
                listParam.Add(new SqlParameter("@PO", this.PO));
            }
            if (Status >= 1)
            {
                sbWhere.Append(" AND RW01032 = @Status ");
                listParam.Add(new SqlParameter("@Status", this.Status));
            }
            List<BaseSearchModel> models = null;
            if (this.doPager)
            {
                int count = 0;
                adoBarcode.PageSize = this.PageSize;
                models = adoBarcode.GetList(this.PageIndex, sbWhere.ToString(), SearchOrderBy, out count, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
                base.totalCount = count;
            }
            else
            {
                models = adoBarcode.GetList(sbWhere.ToString(), SearchOrderBy, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
            }
            return models;
        }
Beispiel #28
0
        public override BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
                throw new Exception("请扫描或输入待入库的条码标签");
            ModelAdo<LocationModel> adoLoc = new ModelAdo<LocationModel>();
            List<LocationModel> lm = adoLoc.GetList("SC36001=@wh and SC36002=@bin", "", "", new SqlParameter("@wh", this.Warehouse), new SqlParameter("@bin", this.Bin));

            if (lm.Count == 0)
                throw new Exception("仓库或库位不存在");
            using (TransactionScope ts = new TransactionScope())
            {

                ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                StringBuilder sb = new StringBuilder();
                foreach (string item in Barcodes)
                {
                    sb.Append(",'" + item + "'");
                }
                sb.Remove(0, 1);

                string sql = @"
            declare @RC int
            declare @result nvarchar(200)
            declare @dj varchar(30)
            set @RC=0
            set @result=N'YES'
            select @RC=count(RW01001) from RW01 where RW01001 IN ([BIDS]) and RW01032>1
            if @RC>0
            begin
            set @result=N'已入库的料不可再入库'
            end
            set @RC=0
            select @RC=count(distinct(RW01014)) from RW01 where RW01001 IN ([BIDS])
            if @RC>1
            begin
            set @result=N'多张采购单请分批收货'
            end
            set @RC=0
            select @RC=count(distinct(RW01043)) from RW01 where RW01001 IN ([BIDS])
            if @RC>1
            begin
            set @result=N'PO收货、WO收货以及STOCK RECEIVE请分开操作'
            end
            if @result='YES'
            begin
            exec PROC_GETID 'RW03',@dj output

            insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008)
            values(@dj,getdate(),@userid,@username,'','','',@Remark)

            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            select RW01001,getdate(),@userid,@username,@dj,N'入库到'+@whstr from RW01 where RW01001 IN ([BIDS])

            insert into RW04(RW04002,RW04003,RW04004,RW04005)
            select getdate(),@dj,RW01001,N'入库到'+@whstr from RW01 where RW01001 IN ([BIDS])

            update RW01 set RW01008=@wh,RW01009=@sh,RW01010=getdate(),RW01024=@userid,RW01025=@username,RW01027=@dj,RW01032=2 where RW01001 IN ([BIDS])

            UPDATE WK01 SET WK01006=getdate() where WK01006 is null and WK01004<= (select sum(RW01006) FROM RW01 WHERE RW01032=2 and RW01033=WK01001 and RW01002=WK01002 GROUP BY RW01033,RW01002)
            end
            select @result MSG
            ";
                sql = sql.Replace("[BIDS]", sb.ToString());
                DataSet ds = adoRW.GetDataSet(sql, new SqlParameter("@Remark", this.Remark), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName),
                    new SqlParameter("@wh", this.Warehouse), new SqlParameter("@sh", this.Bin), new SqlParameter("@whstr", this.Warehouse + "[" + this.Bin + "]"));
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string msg = ds.Tables[0].Rows[0][0] + "";
                    if (msg != "YES")
                        throw new Exception(msg);
                    else
                    {
                        this.ExportXMLPO(sb.ToString());
                    }
                }
                ts.Complete();
                return this;
            }
        }
Beispiel #29
0
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.oid         = Convert.ToInt32(context.Request["oid"]);
            if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token          = new TokenHelper();
                UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
                if (userTokenModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    ModelAdo <OrderModel> orderModel = new ModelAdo <OrderModel>();
                    OrderModel            model      = orderModel.GetModel("id=?id", "",
                                                                           new MySqlParameter("?id", requestBody.oid)
                                                                           );
                    if (model != null)
                    {
                        responseBody                = new ResponseBody();
                        responseBody.uid            = model.uid;
                        responseBody.title          = model.title;
                        responseBody.subtitle       = model.subtitle;
                        responseBody.createDate     = string.Format("{0:d}", StringHelper.GetNomalTime(model.createDate));
                        responseBody.status         = model.ostatus;
                        responseBody.no             = model.no;
                        responseBody.price          = model.amount.ToString("f2");
                        responseBody.contact        = model.contact;
                        responseBody.contactAddress = model.contactAdress;
                        responseBody.contactOPhone  = model.contactOPhone;
                        responseBody.contactPhone   = model.contactPhone;
                        responseBody.payment        = model.payment;
                        responseBody.type           = model.otid;
                        responseBody.remark         = model.remark;
                        Ext from = new Ext();
                        from.uid          = model.uid;
                        from.city         = model.address1;
                        from.date         = string.Format("{0:d}", StringHelper.GetNomalTime(model.time1));
                        responseBody.from = from;

                        Ext to = new Ext();
                        to.uid          = model.uid;
                        to.city         = model.address2;
                        to.date         = string.Format("{0:d}", StringHelper.GetNomalTime(model.time2));
                        responseBody.to = to;

                        if (model.ostatus == 3)
                        {
                            Send send = new Send();
                            send.date         = string.Format("{0:d}", StringHelper.GetNomalTime(model.sendTime));
                            send.suid         = model.sendUid;
                            send.price        = model.sendAmount.ToString("f2");
                            send.remark       = model.sendRemark;
                            responseBody.send = send;
                        }
                        responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                    }
                }
            }
        }
Beispiel #30
0
        public override List<BaseSearchModel> GetALL(bool enableSearch = false)
        {
            ModelAdo<RWInvoiceModel> ado = new ModelAdo<RWInvoiceModel>();
            List<SqlParameter> listParam = new List<SqlParameter>();
            StringBuilder sbWhere = new StringBuilder();
            sbWhere.Append(" 1=1 ");
            if (!BeginInvoiceTime.Equals(DateTime.MinValue) && !EndInvoiceTime.Equals(DateTime.MinValue))
            {
                sbWhere.Append(" AND RW18002 BETWEEN  @BeginInvoiceTime AND @EndInvoiceTime ");
                listParam.Add(new SqlParameter("@BeginInvoiceTime", BeginInvoiceTime));
                listParam.Add(new SqlParameter("@EndInvoiceTime", EndInvoiceTime));

            }

            if (!String.IsNullOrEmpty(this.ID))
            {
                sbWhere.Append(" AND RW18001 = @ID");
                listParam.Add(new SqlParameter("@ID", ID));
            }
            if (Status >= 1)
            {
                sbWhere.Append(" AND RW18005 = @Status ");
                listParam.Add(new SqlParameter("@Status", this.Status));
            }
            List<BaseSearchModel> models = null;
            if (this.doPager)
            {
                int count = 0;
                ado.PageSize = this.PageSize;
                models = ado.GetList(this.PageIndex, sbWhere.ToString(), " RW18001 DESC  ", out count, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
                base.totalCount = count;
            }
            else
            {
                models = ado.GetList(sbWhere.ToString(), " RW18001 DESC  ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
            }
            return models;
        }
Beispiel #31
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request["oid"] == null)
            {
                status = 0;
                msg    = "订单编号参数不能为空!";
                goto returnJson;
            }

            string pageSize = context.Request["pageSize"];
            string oid      = context.Request["oid"];


            ModelAdo <SupplierOrderModel> supplierSendModel = new ModelAdo <SupplierOrderModel>();

            if (pageSize != null)
            {
                supplierSendModel.PageSize = int.Parse(pageSize);
            }

            int RecordCount = supplierSendModel.GetRecordCount(" userType=0  ");
            List <SupplierOrderModel> list = supplierSendModel.GetList(" userType=0 AND (oid=?oid or status is NULL) ", "", "", new MySqlParameter("?oid", oid));


            //List<SupplierOrderModel> list = supplierSendModel.GetList("select * from tv_view_supplier_order  where userType=0 AND (oid=1 or status is NULL) ");

            if (list.Count == 0)
            {
                status = 0;
                msg    = "未能找到数据集合!";
                goto returnJson;
            }
            else
            {
                pageData = new
                {
                    recordCount = RecordCount,
                    pageSize    = supplierSendModel.PageSize
                };
                Data = from model in list
                       select new
                {
                    uid = model.uid,

                    status = model.status,
                    oid    = model.oid
                };
                output = new
                {
                    pageData = pageData,
                    Data     = Data
                };
            }

returnJson:
            Dictionary <string, object> returnJson = new Dictionary <string, object>
            {
                { "status", status },
                { "msg", msg },
                { "output", output }
            };
            string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented);

            context.Response.ContentType = "application/json";
            context.Response.Write(json);
        }
Beispiel #32
0
        public override List<BaseSearchModel> GetALL(bool enableSearch = false)
        {
            ModelAdo<FGBillModel> adoBill = new ModelAdo<FGBillModel>();
            List<SqlParameter> listParam = new List<SqlParameter>();
            StringBuilder sbWhere = new StringBuilder();
            sbWhere.Append(" 1=1 ");
            if (!BeginTime.Equals(DateTime.MinValue) && !EndTime.Equals(DateTime.MinValue))
            {
                sbWhere.Append(" AND FG03002 BETWEEN  @BeginTime AND @EndTime ");
                listParam.Add(new SqlParameter("@BeginTime", BeginTime));
                listParam.Add(new SqlParameter("@EndTime", EndTime));
            }
            if (!string.IsNullOrEmpty(this.ID))
            {
                sbWhere.Append(" AND FG03001 = @ID");
                listParam.Add(new SqlParameter("@ID", ID));
            }
            if (!string.IsNullOrEmpty(this.UserName))
            {
                sbWhere.Append(" AND FG03004=@UserName");
                listParam.Add(new SqlParameter("@UserName", UserName));
            }

            if (!string.IsNullOrEmpty(this.Remark))
            {
                sbWhere.Append(" AND FG03008=@Remark");
                listParam.Add(new SqlParameter("@Remark", Remark));
            }

            return adoBill.GetList(sbWhere.ToString(), " FG03002 DESC ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
        }
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
                throw new Exception("请扫描或输入待入库的条码标签");
            ModelAdo<LocationModel> adoLoc = new ModelAdo<LocationModel>();
            List<LocationModel> lm = adoLoc.GetList("SC36001=@wh and SC36002=@bin", "", "", new SqlParameter("@wh", this.Warehouse), new SqlParameter("@bin", this.Bin));

            if (lm.Count == 0)
                throw new Exception("仓库或库位不存在");

            //①:修改原材料领料单RW08状态 :RW08008	int		状态(1已申请 2部分发货 3关闭)
            //②:修改原材料领料单ITEMRW09已领和剩余数量
            //③:插入RW10	原材料领料单BARCODE	中间表

            //④:修改条码信息表:
            //⑤:插入RW03原材料单据表
            //⑥:插入RW04原材料单据明细表
            //⑦:插入RW02	原材料历史记录
            using (TransactionScope ts = new TransactionScope())
            {
                ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                List<SqlParameter> parameters = new List<SqlParameter>();
                StringBuilder sb = new StringBuilder();
                foreach (string item in Barcodes)
                {
                    sb.Append(",'" + item + "'");
                }
                sb.Remove(0, 1);

                string sql = @"
            declare @RC int
            declare @result nvarchar(200)
            declare @dj varchar(30)
            set @RC=0
            set @result=N'YES'
            select @RC=count(RW01001) from RW01 where RW01001 IN ([BIDS]) and RW01032 <> 2
            if @RC>0
            begin
            set @result=N'存在不能做领料操作的信息,不能进行领料操作'
            end

            if @result='YES'
            begin
            declare @calcstatus int

            Update RW09 set RW09005=@userid,RW09006=@username,RW09011=@ReceivedCount, RW09012=@ReceiveSurplusCount where RW09001=@ReceiveLine

            set @calcstatus=2
            select @calcstatus=SUM(RW09012) from RW09 where RW09003=@ReceiveID
            if @calcstatus>0
            begin
            set @ReceiveStatus=2
            end
            else
            begin
            set @ReceiveStatus=3
            end

            Update RW08 set RW08008=@ReceiveStatus where RW08001=@ReceiveID

            insert into RW10(RW10002,RW10003,RW10004,RW10005,RW10006,RW10007)
            select getdate(),@userid,@username,@ReceiveID,@ReceiveLine,RW01001 from RW01 where RW01001 IN ([BIDS])

            exec PROC_GETID 'RW03',@dj output

            insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008)
            values(@dj,getdate(),@userid,@username,'','',@ReceiveID,@Remark)

            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            select RW01001,getdate(),@userid,@username,@dj,N'领料单['+ @ReceiveID +'];移库到'+@whstr from RW01 where RW01001 IN ([BIDS])

            insert into RW04(RW04002,RW04003,RW04004,RW04005)
            select getdate(),@dj,RW01001,N'领料单['+ @ReceiveID +']; 移库到'+@whstr from RW01 where RW01001 IN ([BIDS])

            update RW01 set RW01016 =RW01008 ,RW01017 = RW01009,RW01008=@wh,RW01009=@sh,RW01024=@userid,RW01025=@username,RW01027=@dj,RW01032=3 where RW01001 IN ([BIDS])

            end
            select @result MSG
            ";

                parameters.Add(new SqlParameter("@userid", this.LoginUserID));
                parameters.Add(new SqlParameter("@username", this.LoginUserName));
                parameters.Add(new SqlParameter("@Remark", this.Remark));
                parameters.Add(new SqlParameter("@ReceiveID", this.ReceiveID));
                parameters.Add(new SqlParameter("@ReceiveStatus", this.ReceiveStatus));
                parameters.Add(new SqlParameter("@ReceiveLine", this.ReceiveLine));
                parameters.Add(new SqlParameter("@ReceivedCount", this.ReceivedCount));
                parameters.Add(new SqlParameter("@ReceiveSurplusCount", this.ReceiveSurplusCount));

                parameters.Add(new SqlParameter("@wh", this.Warehouse));
                parameters.Add(new SqlParameter("@sh", this.Bin));
                parameters.Add(new SqlParameter("@whstr", this.Warehouse + "[" + this.Bin + "]"));

                sql = sql.Replace("[BIDS]", sb.ToString());
                DataSet ds = adoRW.GetDataSet(sql, parameters.ToArray());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string msg = ds.Tables[0].Rows[0][0] + "";
                    if (msg != "YES")
                        throw new Exception(msg);
                    else
                    {
                        this.ExportXML(sb.ToString());
                    }
                }
                ts.Complete();
                return this;
            }
        }
Beispiel #34
0
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            if (Barcodes == null || Barcodes.Length == 0)
                throw new Exception("请扫描或输入待入库的条码标签");

            //①:修改成品发货单单FG08状态 :FG08008	int		状态(1已申请 2部分发货 3关闭)
            //②:修改成品发货单单ITEMFG09已领和剩余数量
            //③:插入FG10	成品发货单单BARCODE	中间表

            //④:修改条码信息表:
            //⑤:插入FG03成品单据表
            //⑥:插入FG04成品单据明细表
            //⑦:插入FG02	成品历史记录
            using (TransactionScope ts = new TransactionScope())
            {
                ModelAdo<FGBarcodeModel> adoFG = new ModelAdo<FGBarcodeModel>();
                List<SqlParameter> parameters = new List<SqlParameter>();
                StringBuilder sb = new StringBuilder();
                foreach (string item in Barcodes)
                {
                    sb.Append(",'" + item + "'");
                }
                sb.Remove(0, 1);

                string sql = @"
            declare @RC int
            declare @lineno varchar(10)
            declare @result nvarchar(200)
            declare @dj varchar(30)
            set @RC=0
            set @result=N'YES'
            select @RC=count(FG01001) from FG01 where FG01001 IN ([BIDS]) and FG01032 <> 2
            if @RC>0
            begin
            set @result=N'存在不能做发货操作的信息,不能进行发货操作'
            end

            if @result='YES'
            begin

            Update FG09 set FG09005=@userid,FG09006=@username,FG09011=@InvoicedCount, FG09012=@InvoiceSurplusCount where FG09001=@InvoiceLine

            select @lineno=FG09002 from FG09 where FG09001=@InvoiceLine

            declare @calcstatus int
            set @calcstatus=2
            select @calcstatus=SUM(FG09012) from FG09 where FG09003=@InvoiceID
            if @calcstatus>0
            begin
            set @InvoiceStatus=2
            end
            else
            begin
            set @InvoiceStatus=3
            end
            Update FG08 set FG08008=@InvoiceStatus where FG08001=@InvoiceID

            insert into FG10(FG10002,FG10003,FG10004,FG10005,FG10006,FG10007)
            select getdate(),@userid,@username,@InvoiceID,@InvoiceLine,FG01001 from FG01 where FG01001 IN ([BIDS])

            exec PROC_GETID 'FG03',@dj output

            insert into FG03(FG03001,FG03002,FG03003,FG03004,FG03005,FG03006,FG03007,FG03008)
            values(@dj,getdate(),@userid,@username,'','',@InvoiceID,@Remark)

            insert into FG02(FG02002,FG02003,FG02004,FG02005,FG02010,FG02011)
            select FG01001,getdate(),@userid,@username,@dj,N'发货单['+ @InvoiceID +']' from FG01 where FG01001 IN ([BIDS])

            insert into FG04(FG04002,FG04003,FG04004,FG04005)
            select getdate(),@dj,FG01001,N'发货单['+ @InvoiceID +']' from FG01 where FG01001 IN ([BIDS])

            update FG01 set FG01016 =FG01008 ,FG01017 = FG01009,FG01024=@userid,FG01025=@username,FG01027=@dj,FG01032=3,FG01030=@InvoiceID,FG01039=@lineno where FG01001 IN ([BIDS])

            end
            select @result MSG
            ";

                parameters.Add(new SqlParameter("@userid", this.LoginUserID));
                parameters.Add(new SqlParameter("@username", this.LoginUserName));
                parameters.Add(new SqlParameter("@Remark", this.Remark));
                parameters.Add(new SqlParameter("@InvoiceID", this.InvoiceID));
                parameters.Add(new SqlParameter("@InvoiceStatus", this.InvoiceStatus));
                parameters.Add(new SqlParameter("@InvoiceLine", this.InvoiceLine));
                parameters.Add(new SqlParameter("@InvoicedCount", this.InvoicedCount));
                parameters.Add(new SqlParameter("@InvoiceSurplusCount", this.InvoiceSurplusCount));

                sql = sql.Replace("[BIDS]", sb.ToString());
                DataSet ds = adoFG.GetDataSet(sql, parameters.ToArray());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string msg = ds.Tables[0].Rows[0][0] + "";
                    if (msg != "YES")
                        throw new Exception(msg);
                    else
                    {
                        this.ExportXML(sb.ToString());
                    }
                }
                ts.Complete();
                return this;
            }
        }
Beispiel #35
0
        public override List<BaseSearchModel> GetALL(bool enableSearch = false)
        {
            ModelAdo<RWHistoryModel> adoRW = new ModelAdo<RWHistoryModel>();
            List<SqlParameter> listParam = new List<SqlParameter>();
            StringBuilder sbWhere = new StringBuilder();
            sbWhere.Append(" 1=1 ");

            if (!string.IsNullOrEmpty(this.BarcodeID))
            {
                sbWhere.Append(" AND RW02002 = @BarcodeID");
                listParam.Add(new SqlParameter("@BarcodeID", this.BarcodeID));
            }

            return adoRW.GetList(sbWhere.ToString(), " RW02001 DESC ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.page        = Convert.ToInt32(context.Request["page"]);
            requestBody.pageSize    = Convert.ToInt32(context.Request["pageSize"]);
            requestBody.status      = Convert.ToInt32(context.Request["status"]);
            if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token          = new TokenHelper();
                UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
                if (userTokenModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    ModelAdo <OrderModel> orderModel = new ModelAdo <OrderModel>();
                    List <OrderModel>     models     = null;
                    int pagenumber = requestBody.page == 0 ? 1 : requestBody.page;
                    int totalCount = 1;
                    orderModel.PageSize = requestBody.pageSize == 0 ? orderModel.PageSize : requestBody.pageSize;
                    if (requestBody.status == 0)
                    {
                        models = orderModel.GetList(pagenumber, " uid=?uid ", "", out totalCount, "",
                                                    new MySqlParameter("?uid", userTokenModel.uid)
                                                    );
                    }
                    else
                    {
                        models = orderModel.GetList(pagenumber, " uid=?uid AND ostatus=?ostatus", "", out totalCount, "",
                                                    new MySqlParameter("?uid", Convert.ToInt32(userTokenModel.uid)),
                                                    new MySqlParameter("?ostatus", requestBody.status)
                                                    );
                    }
                    if (models.Count >= 1)
                    {
                        //构建返回对象
                        List <Order> orders = new List <Order>();
                        foreach (OrderModel model in models)
                        {
                            Order order = new Order();
                            order.uid        = model.uid.ToString();
                            order.title      = model.title;
                            order.createDate = string.Format("{0:d}", StringHelper.GetNomalTime(model.createDate));
                            order.status     = model.ostatus;
                            order.price      = model.amount.ToString("f2");
                            order.oid        = model.id.ToString();
                            order.type       = model.otid;
                            Ext from = new Ext();
                            from.uid   = model.uid.ToString();
                            from.city  = model.address1;
                            from.date  = string.Format("{0:d}", StringHelper.GetNomalTime(model.time1));
                            order.from = from;

                            Ext to = new Ext();
                            to.uid   = model.uid.ToString();
                            to.city  = model.address2;
                            to.date  = string.Format("{0:d}", StringHelper.GetNomalTime(model.time2));
                            order.to = to;

                            orders.Add(order);
                        }
                        responseBody = new ResponseBody
                        {
                            page      = 1,
                            pageTotal = (totalCount + orderModel.PageSize - 1) / orderModel.PageSize,
                            total     = totalCount,
                            orders    = orders
                        };
                        responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                    }
                }
            }
        }
Beispiel #37
0
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.withId      = Convert.ToInt32(context.Request["withId"]);
            requestBody.page        = Convert.ToInt32(context.Request["page"]);
            requestBody.pageSize    = Convert.ToInt32(context.Request["pageSize"]);

            if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.withId == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token          = new TokenHelper();
                UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
                if (userTokenModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    //获取消息列表
                    ModelAdo <MsgModel> modelAdo = new ModelAdo <MsgModel>();
                    int pagenumber = requestBody.page == 0 ? 1 : requestBody.page;
                    int totalCount = 1;
                    modelAdo.PageSize = requestBody.pageSize == 0 ? modelAdo.PageSize : requestBody.pageSize;

                    List <MsgModel> models = models = modelAdo.GetList(pagenumber,
                                                                       "(ufrom=?ufrom AND uto=?uto) or (uto=?ufrom AND ufrom=?uto)", "createTime DESC ", out totalCount, "",
                                                                       new MySqlParameter("?ufrom", userTokenModel.uid),
                                                                       new MySqlParameter("?uto", requestBody.withId)
                                                                       );
                    if (models.Count >= 1)
                    {
                        //构建返回对象
                        List <Msg> msgs = new List <Msg>();
                        models.Sort(new idComparer());
                        foreach (MsgModel model in models)
                        {
                            Msg msg = new Msg();
                            msg.id         = model.id;
                            msg.content    = model.content;
                            msg.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", StringHelper.GetNomalTime(model.createTime));
                            msg.ufrom      = model.ufrom;
                            msg.uto        = model.uto;
                            msg.type       = model.type;
                            msg.status     = model.status;
                            msgs.Add(msg);
                            //处理数据为已读
                            if (msg.status == 0)
                            {
                                model.status = 1;
                                modelAdo.Update(model);
                            }
                        }
                        responseBody = new ResponseBody
                        {
                            page      = 1,
                            pageTotal = (totalCount + modelAdo.PageSize - 1) / modelAdo.PageSize,
                            total     = totalCount,
                            msgs      = msgs
                        };
                        responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented);
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                    }
                }
            }
        }
Beispiel #38
0
        public override BaseSearchModel Insert()
        {
            ModelAdo<WOModel> adoWO = new ModelAdo<WOModel>();
            WOModel modelWO = adoWO.GetModel("MP64001=@wo", "", new SqlParameter("@wo", this.Workorder));
            if (modelWO != null)
            {
                ModelAdo<ReportModel> adoReport = new ModelAdo<ReportModel>();
                List<ReportModel> list = adoReport.GetList("WK02002=@wo", "WK02001", "", new SqlParameter("@wo", this.Workorder));
                if (list.Count == 0)
                {
                    ModelAdo<WOWK01Model> adoWK01 = new ModelAdo<WOWK01Model>();
                    WOWK01Model wk01 = new WOWK01Model()
                    {
                        WorkOrder=modelWO.WorkOrder,
                        StockCode=modelWO.StockCode,
                        StockName=modelWO.StockName,
                        QTY=modelWO.PlanQTY,
                        Status=1,
                        TotalHour=0
                    };
                    adoWK01.Insert(wk01);

                    ModelAdo<WOLineNoGroupModel> adoWOLine = new ModelAdo<WOLineNoGroupModel>();
                    List<WOLineNoGroupModel> wolineList = adoWOLine.GetList("MP65001=@wo", "MP65003", "", new SqlParameter("@wo", this.Workorder));
                    int i = 0;
                    string op = "";
                    foreach (WOLineNoGroupModel item in wolineList)
                    {
                        if (op != item.OperationNO)
                            i = 0;
                        i++;
                        ReportModel modelReport = new ReportModel()
                        {
                            BOMOP = item.OperationNO,
                            BOMOPINDEX = i + "",
                            DeQTY = item.PlanQTY,
                            HadDe = 0,
                            HadDeQTY = 0,
                            StockCode = item.StockCode,
                            StockName = item.StockName,
                            Workorder = item.WO,
                            LineNumber = item.Number,
                            ReportNumber = item.ReportNumber,
                            DeDate = System.DateTime.Now,
                            Warehouse=item.Warehouse
                        };
                        adoReport.Insert(modelReport);
                    }
                }
                //                if (!string.IsNullOrEmpty(this.RWID))
                //                {
                //                    ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                //                    RWBarcodeModel rwModel = adoRW.GetModelByID(this.RWID);
                //                    if (rwModel != null)
                //                    {
                //                        if (this.DeQTY > (float)rwModel.StockUnitQty)
                //                            throw new Exception("汇报数量超出条码数量");

                //                        string sql = @"
                //update RW01 set RW01006=RW01006-@deqty where RW01001=@bid
                //
                //insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
                //select RW01001,getdate(),@userid,@username,@dj,N'扣料 工单号'+@wo+' 数量'+convert(varchar(10),@deqty) from RW01 where RW01001=@bid
                //
                //update WK02 set WK02002=
                //";
                //                    }
                //                    else
                //                        throw new Exception("无效原材料条码");
                //                }
                list = adoReport.GetList("WK02002=@wo", "WK02001", "", new SqlParameter("@wo", this.Workorder));
                this.ReturnReportList = list;
                return this;
            }
            else
                throw new Exception("无效工单,请重新确认工单");
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.oid         = context.Request["oid"];
            requestBody.action      = Convert.ToInt32(context.Request["action"]);
            requestBody.amount      = Convert.ToDecimal(context.Request["money"]);
            if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid.Length == 0 || requestBody.action == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else if (requestBody.action == 2 && requestBody.amount == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                //验证用户
                TokenHelper    token          = new TokenHelper();
                UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
                if (userTokenModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    ModelAdo <OrderUserModel> modelAdo = new ModelAdo <OrderUserModel>();

                    //核对有没有供应商已抢单
                    OrderUserModel sendOrder = modelAdo.GetModel(" oid =?oid AND status=2", "",
                                                                 new MySqlParameter("?oid", requestBody.oid));
                    //核对供应商与订单状态
                    OrderUserModel model = modelAdo.GetModel("oid=?oid AND uid=?uid", "",
                                                             new MySqlParameter("?oid", requestBody.oid),
                                                             new MySqlParameter("?uid", userTokenModel.uid));
                    //数据是否存在派单中间表
                    if (model != null)
                    {
                        #region 供应商确认抢单【派单中间表已存在,并且订单状态为2,派单中】
                        if (2 == requestBody.action && sendOrder == null)
                        {
                            model.status     = 2;
                            model.amount     = requestBody.amount;
                            model.createTime = StringHelper.ConvertDateTimeInt(DateTime.Now);
                            model.remark     = "被供应商抢单的订单";

                            //修改订单状态为3,并录入相关抢单数据
                            ModelAdo <OrderModel> orderModelAdo = new ModelAdo <OrderModel>();
                            OrderModel            orderModel    = orderModelAdo.GetModel("id=?id", "",
                                                                                         new MySqlParameter("?id", requestBody.oid)
                                                                                         );
                            if (orderModel != null)
                            {
                                orderModel.ostatus    = 3;
                                orderModel.sendUid    = Convert.ToInt32(userTokenModel.uid);
                                orderModel.sendTime   = model.createTime;
                                orderModel.sendRemark = "供应商抢单并输入价格 【待处理订单】";
                                orderModel.sendAmount = model.amount;
                                if (orderModelAdo.Update(orderModel) >= 1)
                                {
                                    if (modelAdo.Update(model) >= 1)
                                    {
                                        SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                    }
                                    else
                                    {
                                        SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                                    }
                                }
                            }
                            else
                            {
                                SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                            }
                        }
                        #endregion
                        #region 用户退回订单 【派单中间表已存在,并且订单状态为3,待处理订单】
                        else if (3 == requestBody.action && sendOrder != null && sendOrder.uid == Convert.ToInt32(userTokenModel.uid))
                        {
                            //修改订单状态为2,并清除相关抢单数据
                            ModelAdo <OrderModel> orderModelAdo = new ModelAdo <OrderModel>();
                            OrderModel            orderModel    = orderModelAdo.GetModel("id=?id", "",
                                                                                         new MySqlParameter("?id", requestBody.oid)
                                                                                         );
                            if (orderModel != null)
                            {
                                orderModel.ostatus    = 2;
                                orderModel.sendUid    = 0;
                                orderModel.sendTime   = 0;
                                orderModel.sendRemark = "供应商退回抢单【派单中】";
                                orderModel.sendAmount = 0;
                                if (orderModelAdo.Update(orderModel) >= 1)
                                {
                                    model.status = 3;
                                    model.remark = "被供应商退回的订单";
                                    modelAdo.Update(model);
                                    SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                }
                                else
                                {
                                    SystemResponse.Output(SystemResponse.TYPE_NO_PERMISSON, out statusCode, out responseJson);
                                }
                            }
                            else
                            {
                                SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                            }
                        }
                        #endregion
                        #region 其他操作
                        else
                        {
                            SystemResponse.Output(SystemResponse.TYPE_NO_PERMISSON, out statusCode, out responseJson);
                        }
                        #endregion
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_NO_PERMISSON, out statusCode, out responseJson);
                    }
                }
            }
        }
        public override BaseSearchModel Insert()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                string sql = @"
            declare @dj varchar(30)
            exec PROC_GETID 'RW03',@dj output
            --单据头
            insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008)
            values(@dj,getdate(),@userid,@username,'','','',N'US导入创建条码')
            --装箱标签
            insert into RW07(RW07001,RW07002,RW07003,RW07004,RW07005,RW07006,RW07007,RW07008)
            select RW13017,getdate(),@userid,@username,0,'',0,2 from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13017,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01) group by RW13017
            --单据明细
            insert into RW04(RW04002,RW04003,RW04004,RW04005)
            select getdate(),@dj,RW13010,N'US导入创建条码' from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01)
            --历史记录
            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            select RW13010,getdate(),@userid,@username,@dj,N'US导入创建条码' from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01)
            --原材料
            insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01012,RW01013,RW01014,RW01015,RW01024,RW01025,RW01027,RW01031,RW01032,RW01034,RW01035,RW01037,RW01038,RW01041,RW01043,RW01044,RW01045)
            select RW13010,RW13007,RW13008,RW13009,RW13015,RW13014,RW13018,RW13019,RW13005,RW13006,@userid,@username,@dj,RW13017,1,RW13016,RW13011,RW13012,RW13013,RW13022,'PO',RW13020,RW13021
            from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01)
            --删除成功的
            delete from RW13 where RW13010 in (select RW01001 from RW01)
            ";
                BaseAdo ba = new BaseAdo();
                ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@impno", IMPNO));

                ModelAdo<USBarcodeModel> adoUB = new ModelAdo<USBarcodeModel>();
                this.ReturnUSBarcodes = adoUB.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO));
                ModelAdo<USBarcodeGroup> adoUBG = new ModelAdo<USBarcodeGroup>();
                this.ReturnUSBarcodeGroups = adoUBG.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO));
                ts.Complete();
                return this;
            }
        }
Beispiel #41
0
        /*
        /// <summary>
        /// 创建条码信息
        /// 1:插入,父单据号表;
        /// 2:插入,子单据号明细表;
        /// 3:插入,原材料条码表;
        /// 4:插入,条码历史记录表;
        /// </summary>
        /// <returns></returns>
        public override BaseSearchModel Insert()
        {
            ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>();
            ModelAdo<BillDetailModel> adoBillDetail = new ModelAdo<BillDetailModel>();
            ModelAdo<RWHistoryModel> adoBarcodeHistroy = new ModelAdo<RWHistoryModel>();

            List<RWBarcodeModel> listBarcode = new List<RWBarcodeModel>();
            for (int i = 0; i < BarcodeQTY; i++)
            {

                RWBarcodeModel barcodeModel = new RWBarcodeModel()
                {
                    Bill  = billModel.ID,
                    CompanyCode = this.Company,
                    StockUnit = this.UNITPO,
                    StockCode = this.StockCode,
                    StockName = this.StockName,
                    StockSpec = this.StockSpec,
                    StockUnitQty = this.UNITQTY,
                    SupplierCode = this.SupplierCode,
                    SupplierName = this.SupplierName,
                    Warehouse = this.Warehouse,
                    SO = this.PO,
                    Status = 1,
                    POLine = this.LineNum,
                    WarehouseInTime = DateTime.Now,
                    WarehouseOutTime = DateTime.Now,
                    Remark1 = Remark
                };
                adoBarcode.Insert(barcodeModel);

                listBarcode.Add(barcodeModel);

                BillDetailModel billDetailModel = new BillDetailModel()
                {
                    CreateTime = DateTime.Now,
                    BillID = billModel.ID,
                    BarcodeID = barcodeModel.ID,
                    Remark = billModel.Remark
                };
                adoBillDetail.Insert(billDetailModel);

                RWHistoryModel historyModel = new RWHistoryModel()
                {
                    CreateTime = DateTime.Now,
                    BillID = billModel.ID,
                    BarcodeID = barcodeModel.ID,
                    Remark = billModel.Remark
                };
                adoBarcodeHistroy.Insert(historyModel);

            }
            this.RWBarcodeModels = listBarcode.ToArray();
            return this;
        }
         * */
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            string sql = @"
            declare @bid varchar(30)
            declare @hid int
            declare @i int

            set @i=0
            while @i<@printcount
            begin
            exec PROC_GETID 'RW01',@bid output
            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签')

            insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01012,RW01013,RW01014,RW01015,RW01018,RW01024,RW01025,RW01027,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043,RW01044,RW01045)
            values(@bid,@stock,@stockname,@stockspec,@unit,@qty,@sup,@supname,@po,@poline,@remark,@userid,@username,@dj,1,@company,@SupplierBatch,@ProductionTime ,@ValidityTime,@tqty,@type,'PO',@unitpur,@unitsale)

            insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@dj,@bid,N'创建条码')

            set @i=@i+1
            end
            ";
            ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>();
            StockModel sm = adoStock.GetModelByID(this.StockCode);
            BaseAdo ba = new BaseAdo();
            ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID),
                new SqlParameter("@username", this.LoginUserName),
                new SqlParameter("@stock", this.StockCode),
                new SqlParameter("@stockname", this.StockName),
                new SqlParameter("@stockspec", this.StockSpec),
                new SqlParameter("@unit", this.UNITWH),
                new SqlParameter("@qty", this.UNITQTY),
                new SqlParameter("@tqty", this.Type == "02" ? 1 : sm.UQTY),
                new SqlParameter("@type", sm.StockType),
                new SqlParameter("@po", this.PO),
                new SqlParameter("@poline", this.LineNum),
                new SqlParameter("@sup", this.SupplierCode),
                new SqlParameter("@supname", this.SupplierName),
                new SqlParameter("@remark", this.Remark),
                new SqlParameter("@company", this.Company),
                new SqlParameter("@SupplierBatch", this.SupplierBatch),
                new SqlParameter("@printcount", this.BarcodeQTY),
                new SqlParameter("@ProductionTime", this.ProductionTime),
                new SqlParameter("@ValidityTime", this.ValidityTime),
                new SqlParameter("@dj", this.Danju),
                new SqlParameter("@unitpur", this.PODivisor),
                new SqlParameter("@unitsale", this.SODivisor));
            return this;
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            requestBody             = new RequestBody();
            requestBody.accessToken = context.Request["accessToken"];
            requestBody.oid         = context.Request["oid"];
            requestBody.uid         = context.Request["uid"];
            if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid.Length == 0 || requestBody.uid.Length == 0)
            {
                SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson);
            }
            else
            {
                List <int> values = JsonConvert.DeserializeObject <List <int> >(requestBody.uid);

                //验证用户
                TokenHelper    token          = new TokenHelper();
                UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken);
                if (userTokenModel == null)
                {
                    SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson);
                }
                else
                {
                    //获取订单表数据
                    ModelAdo <OrderModel> modelAdoOrder = new ModelAdo <OrderModel>();
                    OrderModel            orderModel    = modelAdoOrder.GetModel("(id=?id AND ostatus=?ostatus) or (id=?id AND ostatus=?ostatus1) ", "",
                                                                                 new MySqlParameter("?id", requestBody.oid),
                                                                                 new MySqlParameter("?ostatus", 2),
                                                                                 new MySqlParameter("?ostatus1", 1));

                    if (orderModel != null)
                    {
                        ModelAdo <OrderUserModel> modelAdo = new ModelAdo <OrderUserModel>();
                        int existCount = modelAdo.GetRecordCount("oid=?oid",
                                                                 new MySqlParameter("?oid", requestBody.oid));
                        if (existCount >= 1)
                        {
                            int delCount = modelAdo.ExecuteSql("DELETE FROM ct_order_user WHERE oid=?oid",
                                                               new MySqlParameter("?oid", requestBody.oid));
                            if (delCount >= 1)
                            {
                                StringBuilder sbValues = new StringBuilder();
                                sbValues.Append(" INSERT INTO ct_order_user(oid,uid,status,remark) VALUES ");
                                for (int i = 0; i < values.Count; i++)
                                {
                                    sbValues.Append("(" + requestBody.oid + "," + values[i] + ",1,'派送中的订单'),");
                                }
                                sbValues.Remove(sbValues.Length - 1, 1).Append(";");
                                int inCount = modelAdo.ExecuteSql(sbValues.ToString());
                                if (inCount >= 1)
                                {
                                    if (orderModel != null)
                                    {
                                        orderModel.ostatus = 2;
                                        modelAdoOrder.Update(orderModel);
                                    }
                                    SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                                }
                                else
                                {
                                    SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                                }
                            }
                            else
                            {
                                SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson);
                            }
                        }
                        else
                        {
                            StringBuilder sbValues = new StringBuilder();
                            sbValues.Append(" INSERT INTO ct_order_user(oid,uid,status) VALUES ");
                            for (int i = 0; i < values.Count; i++)
                            {
                                sbValues.Append("(" + requestBody.oid + "," + values[i] + ",1),");
                            }
                            sbValues.Remove(sbValues.Length - 1, 1).Append(";");
                            int inCount = modelAdo.ExecuteSql(sbValues.ToString());
                            if (inCount >= 1)
                            {
                                SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson);
                            }
                            else
                            {
                                SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                            }
                        }
                    }
                    else
                    {
                        SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson);
                    }
                }
            }
        }
Beispiel #43
0
        public override BaseSearchModel Insert()
        {
            if (Count >= 1)
            {
                ModelAdo<PackingModel> modelAdo = new ModelAdo<PackingModel>();
                string[] strs = new string[Count];
                List<PackingModel> list = new List<PackingModel>();
                for (int i = 0; i < Count; i++)
                {
                    PackingModel pm = this.MemberwiseClone() as PackingModel;
                    pm.CreateTime = DateTime.Now;
                    pm.Status = 1;
                    strs[i] = pm.ID;
                    modelAdo.Insert(pm);

                    list.Add(pm);
                }
                this.PackingModels = list.ToArray() ;
                this.ReturnID = strs;
            }
            return this;
        }
Beispiel #44
0
        public override BarcodeModel.MODEL.BaseSearchModel Insert()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>();
                RWBarcodeModel barcode = adoRW.GetModelByID(this.RWID);
                ModelAdo<ReportModel> adoRM = new ModelAdo<ReportModel>();
                ReportModel rm = adoRM.GetModelByID(this.ReportLineID + "");
                if (barcode.Warehouse != rm.Warehouse)
                {
                    throw new Exception("此工单需汇报" + rm.Warehouse + "仓库的料");
                }
                string sql = @"
            declare @lineno varchar(30)
            declare @reportnumber varchar(30)
            declare @stock varchar(40)
            declare @stocktype varchar(40)
            declare @barcodeQTY numeric(15,3)

            select @wo=WK02002,@lineno=WK02012,@reportnumber=WK02013 from WK02 where WK02001=@rlid
            select @stock=RW01002,@stocktype=RW01041,@barcodeQTY=RW01006 from RW01 where RW01001=@bid
            if(@barcodeQTY=@deqty)
            update RW01 set RW01032=3 where RW01001=@bid
            else
            update RW01 set RW01006=RW01006-@deqty where RW01001=@bid

            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02011)
            select RW01001,getdate(),@userid,@username,N'扣料 工单号'+@wo+' 数量'+convert(varchar(10),@deqty) from RW01 where RW01001=@bid

            update WK02 set WK02008=case when WK02008 is null then getdate() else WK02008 end,WK02009=WK02009+@deqty,WK02010=@wc where WK02001=@rlid
            update WK01 set WK01005=getdate() where WK01001=@wo and WK01005 is null and WK01006 is null

            if not exists(select * from WK04 where WK04001=@wo and WK04002=@wc and WK04004 is null)
            insert into WK04(WK04001,WK04002,WK04003)
            values(@wo,@wc,getdate())

            if not exists(select * from WK02 where WK02002=@wo and WK02009<WK02005)
            update WK01 set WK01008=3 where WK01001=@wo
            else
            update WK01 set WK01008=2 where WK01001=@wo

            insert into WK05(WK05002,WK05003,WK05004,WK05005,WK05006,WK05007,WK05008,WK05009,WK05010)
            values(@wc,@wo,@bid,@stock,@deqty,@stocktype,getdate(),case @stocktype when '02' then 1 else 0 end,@rlid)

            select @wo WO,@reportnumber RN,@lineno LN,RW01017,RW01008,RW01009,RW01002,RW01006/RW01040 RW01006,RW01007,RW01034,RW01035,RW01041 from RW01 where RW01001=@bid
            ";
                BaseAdo ba = new BaseAdo();
                DataSet ds = ba.GetDataSet(sql,
                        new SqlParameter("@userid", this.LoginUserID),
                        new SqlParameter("@username", this.LoginUserName),
                        new SqlParameter("@wo", this.WorkOrder),
                        new SqlParameter("@bid", this.RWID),
                        new SqlParameter("@deqty", this.DeQTY),
                        new SqlParameter("@rlid", this.ReportLineID),
                        new SqlParameter("@wc", this.WorkCenter));

                if (ds.Tables[0].Rows[0]["RW01041"] + "" != "04" && ds.Tables[0].Rows[0]["RW01041"] + "" != "00")
                {
                    List<Hashtable> list = new List<Hashtable>();
                    Hashtable h = new Hashtable();
                    //h["Qty"] = ds.Tables[0].Rows[0]["RW01006"];
                    h["Qty"] = this.DeQTY;
                    h["StockCode"] = ds.Tables[0].Rows[0]["RW01002"];
                    h["ReportNumber"] = ds.Tables[0].Rows[0]["RN"];
                    h["LineNumber"] = ds.Tables[0].Rows[0]["LN"];
                    h["Bin"] = ds.Tables[0].Rows[0]["RW01009"];
                    h["Company"] = ds.Tables[0].Rows[0]["RW01034"];
                    h["SupplierBatch"] = ds.Tables[0].Rows[0]["RW01035"];
                    h["WorkOrder"] = ds.Tables[0].Rows[0]["WO"];
                    h["Warehouse"] = ds.Tables[0].Rows[0]["RW01008"];
                    list.Add(h);
                    StockTransactionXml.ExportWOReportXML(list);
                }
                ts.Complete();
                return this;
            }
        }
Beispiel #45
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request["oid"] == null)
            {
                status = 0;
                msg    = "订单编号参数不能为空!";
                goto returnJson;
            }
            if (context.Request["type"] == null)
            {
                status = 0;
                msg    = "派单类型参数不能为空!";
                goto returnJson;
            }
            if (context.Request["stid"] == null)
            {
                status = 0;
                msg    = "供应商组编号参数不能为空!";
                goto returnJson;
            }
            int    oid  = Int32.Parse(context.Request["oid"]);
            int    type = Int32.Parse(context.Request["type"]);
            string stid = context.Request["stid"];


            ModelAdo <OrderSTypeModel> orderSTypeModel = new ModelAdo <OrderSTypeModel>();

            if (type == 1)
            {
                int RecordCount = orderSTypeModel.GetRecordCount(" oid = " + oid);
                if (RecordCount >= 1)
                {
                    //删除原有中间表数据
                    int tempSize = orderSTypeModel.ExecuteSql("DELETE FROM ct_order_stype WHERE oid = ?oid",
                                                              new MySqlParameter("?oid", oid));
                    if (tempSize == 0)
                    {
                        //删除成功,插入数据
                    }
                    else
                    {
                        //未能正确删除数据
                        status = 0;
                        msg    = "数据处理失败集合!";
                        goto returnJson;
                    }
                }
                //直接插入数据
                JArray jsonStid = JArray.Parse(stid);
                if (jsonStid.Count == 0)
                {
                    //供应商组不能为空
                    status = 0;
                    msg    = "供应商组不能为空!";
                    goto returnJson;
                }
                string insertStr = "INSERT INTO ct_order_stype(oid,stid,status) VALUES";
                foreach (int item in jsonStid)
                {
                    insertStr += "(" + oid + "," + item + ",1),";
                }
                insertStr = insertStr.Substring(0, insertStr.Length - 1);
                output    = insertStr;
            }



            if (0 == 0)
            {
                status = 0;
                msg    = "未能找到数据集合!";
                goto returnJson;
            }
            else
            {
            }

returnJson:
            Dictionary <string, object> returnJson = new Dictionary <string, object>
            {
                { "status", status },
                { "msg", msg },
                { "output", output }
            };
            string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented);

            context.Response.ContentType = "application/json";
            context.Response.Write(json);
        }
Beispiel #46
0
 public override List<BaseSearchModel> GetALL(bool enableSearch = false)
 {
     ModelAdo<ReceiveDetailModel> adoRDetails = new ModelAdo<ReceiveDetailModel>();
     List<SqlParameter> listParam = new List<SqlParameter>();
     StringBuilder sbWhere = new StringBuilder();
     sbWhere.Append(" 1=1 ");
     if (!string.IsNullOrEmpty(ReceiveID))
     {
         sbWhere.Append(" AND RW09003 = @ReceiveID ");
         listParam.Add(new SqlParameter("@ReceiveID", this.ReceiveID));
     }
     List<BaseSearchModel> models = null;
     if (this.doPager)
     {
         int count = 0;
         adoRDetails.PageSize = this.PageSize;
         models = adoRDetails.GetList(this.PageIndex, sbWhere.ToString(), " RW09001 DESC  ", out count, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
         base.totalCount = count;
     }
     else
     {
         models = adoRDetails.GetList(sbWhere.ToString(), " RW09001 DESC  ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel);
     }
     return models;
 }
Beispiel #47
0
        public override BaseSearchModel Insert()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                if (PrintCount == 0)
                {
                    throw new Exception("打印数量不能为空!");
                }
                string sqlStr = @"
            declare @bid varchar(30)
            declare @hid int
            declare @i int
            declare @dj varchar(30)

            exec PROC_GETID 'RW03',@dj output
            insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008)
            values(@dj,getdate(),@userid,@username,'','','',N'创建条码')

            set @i=0
            while @i<@printcount
            begin
            exec PROC_GETID 'RW01',@bid output
            insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011)
            values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签')

            insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01012,RW01013,RW01014,RW01015,RW01018,RW01024,RW01025,RW01027,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043)
            values(@bid,@stock,@stockname,@stockspec,@unit,@qty,@sup,@supname,@po,@poline,@remark,@userid,@username,@dj,1,@company,@SupplierBatch,@ProductionTime ,@ValidityTime,@tqty,@type,'REC')

            insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@dj,@bid,N'创建条码')

            set @i=@i+1
            end
            select top [COUNT] RW01001 from RW01 order by RW01001 desc
            ";
                sqlStr = sqlStr.Replace("[COUNT]", this.PrintCount + "");
                ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>();
                StockModel sm = adoStock.GetModelByID(this.StockCode);
                BaseAdo ba = new BaseAdo();
                DataSet ds = ba.GetDataSet(sqlStr, new SqlParameter("@userid", this.LoginUserID),
                                  new SqlParameter("@username", this.LoginUserName),
                                  new SqlParameter("@stock", this.StockCode),
                                  new SqlParameter("@stockname", sm.StockName),
                                  new SqlParameter("@stockspec", sm.StockSpec),
                                  new SqlParameter("@unit", this.StockUnit),
                                  new SqlParameter("@qty", this.StockUnitQty),
                                  new SqlParameter("@tqty", sm.StockType == "02" ? 1 : sm.UQTY),
                                  new SqlParameter("@po", this.PO),
                                  new SqlParameter("@poline", this.POLine),
                                  new SqlParameter("@sup", this.SupplierCode),
                                  new SqlParameter("@supname", this.SupplierName),
                                  new SqlParameter("@remark", this.Remark1),
                                  new SqlParameter("@company", this.CompanyCode),
                                  new SqlParameter("@SupplierBatch", this.SupplierBatch),
                                  new SqlParameter("@printcount", this.PrintCount),
                                  new SqlParameter("@type", sm.StockType),
                                  new SqlParameter("@ProductionTime", this.ProductDate),
                                  new SqlParameter("@ValidityTime", this.ExpirationDate)
                                  );
                //StringBuilder sb = new StringBuilder();
                //foreach (DataRow item in ds.Tables[0].Rows)
                //{
                //    sb.Append(",'" + item[0] + "'");
                //}
                //sb.Remove(0, 1);
                //ExportXML(sb.ToString());
                ts.Complete();
            }
            return this;
        }