/// <summary>
        /// 新增领用信息
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>
        public bool AddNew(Models.ys_ApplyOrder model)
        {
            AddDicByOrder(model);
            foreach (Models.ys_ApplyOrderDetail d in model.Detail)
            {
                KeyValuePair <SqlParameter[], string> item = StatusChangeSerivce.AddNew("领用", model.ApplyNo, d.AssetsId, model.OperatorId.ToString(), model.OperatorName, model.ApplyUserId.ToString(), model.ApplyUserName);
                sqlDic.Add(item.Key, item.Value);

                AddDicByOrderDetail(d);
                AddDicByUpdateAssets(d.AssetsId, model.ApplyDepartmentId, model.ApplyUserId, model.Location);
            }
            return(Models.SqlHelper.ExecuteTransaction1(sqlDic, false) > 0 ? true :false);
        }
        public void AddLyOrder()
        {
            Models.ys_ApplyOrder  lyModel           = new Models.ys_ApplyOrder();
            BLL.ApplyOrderManager applyOrderManager = new BLL.ApplyOrderManager();
            if (cbtlDepartment.EditValue != null || cbtlDepartment.EditValue != null)
            {
                lyModel.ApplyNo  = applyOrderManager.GetNewApplyNo();//生成订单号
                lyModel.Id       = Guid.NewGuid();
                lyModel.Location = cblocation.Text;

                lyModel.ApplyUserId   = Utils.cls.clsPublic.GetObjGUID(cbUser.EditValue);
                lyModel.ApplyUserName = cbUser.Text;

                if (cbtlDepartment.EditValue == null)
                {
                    lyModel.ApplyDepartmentId = Utils.cls.clsPublic.GetObjGUID(cbUser.Properties.View.GetFocusedRowCellValue("DepartmentId"));
                }
                else
                {
                    lyModel.ApplyDepartmentId = Utils.cls.clsPublic.GetObjGUID(cbtlDepartment.EditValue);
                }

                lyModel.OperatorId   = clsSession._UserId;
                lyModel.OperatorName = clsSession._FullName;
                lyModel.Description  = "登记时生成";
                lyModel.Applyday     = DateTime.Now;

                List <Models.ys_ApplyOrderDetail> details = new List <Models.ys_ApplyOrderDetail>();

                Models.ys_ApplyOrderDetail d = new Models.ys_ApplyOrderDetail();
                model         = assetsManager.GetOneById(model.Id);
                d.AssetsId    = model.Id;
                d.ApplyId     = lyModel.Id;
                d.OldStatusId = model.StatusId;
                details.Add(d);

                lyModel.Detail = details;
                //生成新的领用单
                if (applyOrderManager.AddNew(lyModel))
                {
                    clsPublic.ShowMessage("领用单生成成功!", Text);
                }
                else
                {
                    clsPublic.ShowMessage("领用单生成失败!", Text);
                }
            }
        }
        /// <summary>
        /// 订单信息
        /// </summary>
        /// <param name="model">明细实体</param>
        private void AddDicByOrder(Models.ys_ApplyOrder model)
        {
            string sqlText = @"INSERT INTO [AssetsSys].[dbo].[ys_ApplyOrder]
           ([Id]
           ,[ApplyNo]
           ,[ApplyUserId]
           ,[OperatorId]
           ,[ApplyDepartmentId]
           ,[Location]
           ,[Applyday]
           ,[Description]
           ,[IsAudit]
           ,[IsRemoved]
           ,[CreateTime])
     VALUES
           (@Id
           ,@ApplyNo
           ,@ApplyUserId
           ,@OperatorId
           ,@ApplyDepartmentId
           ,@Location
           ,@Applyday
           ,@Description
           ,@IsAudit
           ,@IsRemoved
           ,@CreateTime)";

            SqlParameter s1  = new SqlParameter("@Id", model.Id);
            SqlParameter s2  = new SqlParameter("@ApplyNo", model.ApplyNo);
            SqlParameter s3  = new SqlParameter("@ApplyUserId", model.ApplyUserId);
            SqlParameter s4  = new SqlParameter("@OperatorId", model.OperatorId);
            SqlParameter s5  = new SqlParameter("@ApplyDepartmentId", model.ApplyDepartmentId);
            SqlParameter s6  = new SqlParameter("@Location", model.Location);
            SqlParameter s7  = new SqlParameter("@Applyday", model.Applyday);
            SqlParameter s8  = new SqlParameter("@Description", model.Description);
            SqlParameter s9  = new SqlParameter("@IsAudit", model.IsAudit);
            SqlParameter s10 = new SqlParameter("@CreateTime", model.CreateTime);
            SqlParameter s11 = new SqlParameter("@IsRemoved", model.IsRemoved);

            SqlParameter[] cmdPara = new SqlParameter[] { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 };
            sqlDic.Add(cmdPara, sqlText);
        }
Example #4
0
 /// <summary>
 /// 新增领用信息
 /// </summary>
 /// <param name="model">实体</param>
 /// <returns></returns>
 public bool AddNew(Models.ys_ApplyOrder model)
 {
     return(sev.AddNew(model));
 }