/// <summary>
        /// 得到一个代码项表实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>代码项表实体</returns>
        public CodeItemsEntity GetModel(string setCode, string code)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@setCode", SqlDbType.VarChar, 50),
                new SqlParameter("@code",    SqlDbType.VarChar, 50)
            };
            parameters[0].Value = setCode;
            parameters[1].Value = code;

            DataSet ds = SQLServerHelper.RunProcedure("uspWip_GetSingleCodeItems", parameters, "pagetable");

            CodeItemsEntity model = new CodeItemsEntity();

            if (ds.Tables[0].Rows.Count > 0)
            {
                var dataRow = ds.Tables[0].Rows[0];

                if (dataRow["id"].ToString() != "")
                {
                    model.id = int.Parse(dataRow["id"].ToString());
                }
                model.code    = dataRow["code"].ToString();
                model.name    = dataRow["name"].ToString();
                model.setCode = dataRow["setCode"].ToString();
                model.note    = dataRow["note"].ToString();
                if (dataRow["delFlag"].ToString() != "")
                {
                    if ((dataRow["delFlag"].ToString() == "1") || (dataRow["delFlag"].ToString().ToLower() == "true"))
                    {
                        model.delFlag = true;
                    }
                    else
                    {
                        model.delFlag = false;
                    }
                }
                model.creator = dataRow["creator"].ToString();
                if (dataRow["createTime"].ToString() != "")
                {
                    model.createTime = DateTime.Parse(dataRow["createTime"].ToString());
                }
                model.lastModifier = dataRow["lastModifier"].ToString();
                if (dataRow["lastModifyTime"].ToString() != "")
                {
                    model.lastModifyTime = DateTime.Parse(dataRow["lastModifyTime"].ToString());
                }


                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获得代码项表数据列表
        /// </summary>
        private List <CodeItemsEntity> DataTableToList(DataTable dt)
        {
            List <CodeItemsEntity> modelList = new List <CodeItemsEntity>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                CodeItemsEntity model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CodeItemsEntity();
                    var dataRow = dt.Rows[n];

                    if (dataRow["id"].ToString() != "")
                    {
                        model.id = int.Parse(dataRow["id"].ToString());
                    }
                    model.code        = dataRow["code"].ToString();
                    model.name        = dataRow["name"].ToString();
                    model.setCode     = dataRow["setCode"].ToString();
                    model.setCodeName = dataRow["setCodeName"].ToString();
                    model.note        = dataRow["note"].ToString();
                    if (dataRow["delFlag"].ToString() != "")
                    {
                        if ((dataRow["delFlag"].ToString() == "1") || (dataRow["delFlag"].ToString().ToLower() == "true"))
                        {
                            model.delFlag = true;
                        }
                        else
                        {
                            model.delFlag = false;
                        }
                    }
                    model.creator = dataRow["creator"].ToString();
                    if (dataRow["createTime"].ToString() != "")
                    {
                        model.createTime = DateTime.Parse(dataRow["createTime"].ToString());
                    }
                    model.lastModifier = dataRow["lastModifier"].ToString();
                    if (dataRow["lastModifyTime"].ToString() != "")
                    {
                        model.lastModifyTime = DateTime.Parse(dataRow["lastModifyTime"].ToString());
                    }



                    modelList.Add(model);
                }
            }
            return(modelList);
        }
        /// <summary>
        /// 增加一条代码项表数据
        /// </summary>
        /// <param name="model">要插入的代码项表实体</param>
        /// <param name="transModel">事务类</param>
        /// <returns>插入生成的最新主键值</returns>
        public int Add(CodeItemsEntity model, TransactionModel transModel = null)
        {
            SqlParameter param_id = new SqlParameter();

            param_id.ParameterName = "@id";
            param_id.SqlDbType     = SqlDbType.Int;
            param_id.Direction     = ParameterDirection.Output;

            SqlParameter[] parameters =
            {
                new SqlParameter("@code",           SqlDbType.NVarChar,  100),
                new SqlParameter("@name",           SqlDbType.NVarChar,  200),
                new SqlParameter("@setCode",        SqlDbType.NVarChar,   20),
                new SqlParameter("@note",           SqlDbType.NVarChar,  200),
                new SqlParameter("@delFlag",        SqlDbType.Bit,         1),
                new SqlParameter("@creator",        SqlDbType.NVarChar,  256),
                new SqlParameter("@createTime",     SqlDbType.DateTime),
                new SqlParameter("@lastModifier",   SqlDbType.NVarChar,  256),
                new SqlParameter("@lastModifyTime", SqlDbType.DateTime),
                param_id
            };
            parameters[0].Value = model.code;
            parameters[1].Value = model.name;
            parameters[2].Value = model.setCode;
            parameters[3].Value = model.note;
            parameters[4].Value = model.delFlag;
            parameters[5].Value = model.creator;
            parameters[6].Value = model.createTime;
            parameters[7].Value = model.lastModifier;
            parameters[8].Value = model.lastModifyTime;


            int rowsAffected;

            if (transModel != null)
            {
                SQLServerHelper.RunProcedure(transModel.conn, transModel.trans, "uspWip_AddCodeItems", parameters, out rowsAffected);
            }
            else
            {
                SQLServerHelper.RunProcedure("uspWip_AddCodeItems", parameters, out rowsAffected);
            }
            return((int)parameters[parameters.Length - 1].Value);
        }
        /// <summary>
        /// 更新一条代码项表数据
        /// </summary>
        /// <param name="model">要更新的代码项表实体</param>
        /// <param name="transModel">事务类</param>
        /// <returns>是否更新成功</returns>
        public bool Update(CodeItemsEntity model, TransactionModel transModel = null)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             SqlDbType.Int,         4),
                new SqlParameter("@code",           SqlDbType.NVarChar,  100),
                new SqlParameter("@name",           SqlDbType.NVarChar,  200),
                new SqlParameter("@setCode",        SqlDbType.NVarChar,   20),
                new SqlParameter("@note",           SqlDbType.NVarChar,  200),
                new SqlParameter("@delFlag",        SqlDbType.Bit,         1),
                new SqlParameter("@lastModifier",   SqlDbType.NVarChar,  256),
                new SqlParameter("@lastModifyTime", SqlDbType.DateTime),
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.code;
            parameters[2].Value = model.name;
            parameters[3].Value = model.setCode;
            parameters[4].Value = model.note;
            parameters[5].Value = model.delFlag;
            parameters[6].Value = model.lastModifier;
            parameters[7].Value = model.lastModifyTime;


            int rowsAffected = 0;

            if (transModel != null)
            {
                SQLServerHelper.RunProcedure(transModel.conn, transModel.trans, "uspWip_UpdateCodeItems", parameters, out rowsAffected);
            }
            else
            {
                SQLServerHelper.RunProcedure("uspWip_UpdateCodeItems", parameters, out rowsAffected);
            }
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 更新一条代码项表数据
 /// </summary>
 /// <param name="model">要更新的代码项表实体</param>
 /// <returns>是否更新成功</returns>
 public bool Update(CodeItemsEntity model)
 {
     model.lastModifyTime = DateTime.Now;
     return(codeItemsDAL.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条代码项表数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns>插入的最新主键值</returns>
 public int Add(CodeItemsEntity model)
 {
     model.createTime = model.lastModifyTime = DateTime.Now;
     model.delFlag    = false;
     return(codeItemsDAL.Add(model));
 }
Beispiel #7
0
        /// <summary>
        /// 插入代码项表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ReturnBody <string> InsertCodeItems(CodeItemsEntity model)
        {
            ReturnBody <string> retBody   = null;
            ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <CodeItemsEntity>(namespaceName, "InsertCodeItems", model);

            try
            {
                #region 验证
                if (model == null)
                {
                    exception.exceptionMsg = ResMsg.PARAMETERNOEMPTY;
                    retBody = BLLHelpler.GetReturnBody <string>(ResCode.PARAMETERNOEMPTY, ResMsg.PARAMETERNOEMPTY, exception);
                    return(retBody);
                }
                List <ColumnsModel> columnsList = new List <ColumnsModel>()
                {
                    new ColumnsModel()
                    {
                        ChinaName = "代码项编码", PropertyName = "code"
                    },
                    new ColumnsModel()
                    {
                        ChinaName = "代码项名称", PropertyName = "name"
                    },
                    new ColumnsModel()
                    {
                        ChinaName = "代码编码", PropertyName = "setCode"
                    },
                    new ColumnsModel()
                    {
                        ChinaName = "说明", PropertyName = "note"
                    },
                    new ColumnsModel()
                    {
                        ChinaName = "创建时间", PropertyName = "createTime", DataType = typeof(DateTime), IsNullable = true
                    },
                    new ColumnsModel()
                    {
                        ChinaName = "修改时间", PropertyName = "lastModifyTime", DataType = typeof(DateTime), IsNullable = true
                    },
                };

                ValidateResModel res = ValidateDataHelper.ValidateNullOrEmpty <CodeItemsEntity>(columnsList, model);
                if (res != null && !res.IsValidate)
                {
                    exception.exceptionMsg = res.ValidateMsg;
                    retBody = BLLHelpler.GetReturnBody <string>(ResCode.PARAMETERNOEMPTY, res.ValidateMsg, exception);
                    return(retBody);
                }
                //验证重复
                if (codeItemsBLL.Exists(model.setCode, model.code))
                {
                    exception.exceptionMsg = "数据已经存在";
                    retBody = BLLHelpler.GetReturnBody <string>(ResCode.FAILURE, exception.exceptionMsg, exception);
                    return(retBody);
                }
                #endregion

                model.delFlag    = false;
                model.createTime = model.lastModifyTime = DateTime.Now;

                if (codeItemsBLL.Add(model) > 0)
                {
                    retBody = BLLHelpler.GetReturnBody <string>(ResCode.SUCCESS, ResMsg.SUCCESS);
                }
                else
                {//失败
                    exception.exceptionMsg = "保存数据失败";
                    retBody = BLLHelpler.GetReturnBody <string>(ResCode.FAILURE, exception.exceptionMsg, exception);
                }
                return(retBody);
            }
            catch (Exception ex)
            {
                WipLogHelper.GetExceptionInfoForError(ex, ref exception);
                retBody = BLLHelpler.GetReturnBody <string>(ResCode.FAILURE, ResMsg.FAILURE + ":" + ex.Message, exception);
                return(retBody);
            }
        }
Beispiel #8
0
 public string UpdateCodeItems0(CodeItemsEntity model)
 {
     return("OK");
 }
Beispiel #9
0
 public string InsertCodeItems0(CodeItemsEntity model)
 {
     return("OK");
 }