コード例 #1
0
 public bool GetSpecialReturnMaterialByID(ref SpecialReturnMaterial model, UserInfo user, ref string strError)
 {
     try
     {
         using (SqlDataReader dr = _db.GetSpecialReturnMaterialByID(model))
         {
             if (dr.Read())
             {
                 model = (GetModelFromDataReader(dr));
                 return(true);
             }
             else
             {
                 strError = "找不到任何数据";
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
     finally
     {
     }
 }
コード例 #2
0
        public SqlDataReader GetSpecialReturnMaterialByID(SpecialReturnMaterial model)
        {
            string strSql = string.Empty;

            strSql = string.Format("SELECT * FROM T_SpecialReturnMaterial WHERE ID = {0}", model.ID);

            return(OperationSql.ExecuteReader(CommandType.Text, strSql, null));
        }
コード例 #3
0
 public bool DeleteSpecialReturnMaterialByID(SpecialReturnMaterial model, UserInfo user, ref string strError)
 {
     try
     {
         return(_db.DeleteSpecialReturnMaterialByID(model));
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
コード例 #4
0
        private SpecialReturnMaterial GetModelFromDataReader(SqlDataReader dr)
        {
            SpecialReturnMaterial model = new SpecialReturnMaterial();

            model.ID         = dr["ID"].ToInt32();
            model.IsDel      = dr["ISDEL"].ToInt32();
            model.Creater    = dr["CREATER"].ToDBString();
            model.CreateTime = dr["CREATETIME"].ToDateTime();
            model.Modifyer   = dr["MODIFYER"].ToDBString();
            model.ModifyTime = dr["MODIFYTIME"].ToDateTimeNull();
            model.InvtID     = dr["InvtID"].ToDBString();

            return(model);
        }
コード例 #5
0
        private string GetFilterSql(SpecialReturnMaterial model, UserInfo user)
        {
            try
            {
                string strSql   = " Where ISNULL(IsDel,1) = 1 ";
                bool   hadWhere = true;

                if (!string.IsNullOrEmpty(model.InvtID))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " (InvtID LIKE '%" + model.InvtID + "%' ) ";
                    hadWhere = true;
                }

                //if (!string.IsNullOrEmpty(model.pName))
                //{
                //    strSql = Common_Func.AddWhereAnd(strSql, hadWhere);
                //    strSql += " HouseName LIKE '%" + model.pName + "%' ";
                //    hadWhere = true;
                //}

                if (!string.IsNullOrEmpty(model.Creater))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " Creater Like '%" + model.Creater + "%' ";
                    hadWhere = true;
                }

                if (model.StartTime != null)
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " CreateTime >= " + model.StartTime.ToDateTime().Date.ToSqlTimeString() + " ";
                    hadWhere = true;
                }

                if (model.EndTime != null)
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " CreateTime <= " + model.EndTime.ToDateTime().AddDays(1).Date.ToSqlTimeString() + " ";
                    hadWhere = true;
                }


                return(strSql);
            }
            catch
            {
                return(string.Empty);
            }
        }
コード例 #6
0
        public bool SaveSpecialReturnMaterial(ref SpecialReturnMaterial model)
        {
            SqlParameter[] param = GetParameterFromModel(model);

            OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_SaveSpecialReturnMaterial", param);

            string ErrorMsg = param[0].Value.ToDBString();

            if (ErrorMsg.StartsWith("execution error"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                model.ID         = param[1].Value.ToInt32();
                model.CreateTime = param[param.Length - 3].Value.ToDateTime();
                model.ModifyTime = param[param.Length - 1].Value.ToDateTimeNull();
                return(true);
            }
        }
コード例 #7
0
 public bool SaveSpecialReturnMaterial(ref SpecialReturnMaterial model, UserInfo user, ref string strError)
 {
     try
     {
         if (model.ID <= 0)
         {
             model.Creater = user.UserNo;
         }
         else
         {
             model.Modifyer = user.UserNo;
         }
         return(_db.SaveSpecialReturnMaterial(ref model));
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
コード例 #8
0
        public bool DeleteSpecialReturnMaterialByID(SpecialReturnMaterial model)
        {
            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000),

                new SqlParameter("@v_ID", model.ID.ToSqlValue()),
            };
            param[0].Direction = ParameterDirection.Output;

            OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_DeleteSpecialReturnMaterialByID", param);

            string ErrorMsg = param[0].Value.ToDBString();

            if (ErrorMsg.StartsWith("execution error"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                return(true);
            }
        }
コード例 #9
0
        private SqlParameter[] GetParameterFromModel(SpecialReturnMaterial model)
        {
            int i;

            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000),

                new SqlParameter("@v_ID", model.ID.ToSqlValue()),
                new SqlParameter("@v_IsDel", model.IsDel.ToSqlValue()),
                new SqlParameter("@v_Creater", model.Creater.ToSqlValue()),
                new SqlParameter("@v_CreateTime", model.CreateTime.ToSqlValue()),
                new SqlParameter("@v_Modifyer", model.Modifyer.ToSqlValue()),
                new SqlParameter("@v_ModifyTime", model.ModifyTime.ToSqlValue()),
                new SqlParameter("@v_InvtID", model.InvtID.ToSqlValue()),
            };
            i = 0;
            param[i++].Direction = ParameterDirection.Output;
            param[i++].Direction = ParameterDirection.InputOutput;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;


            i = 0;
            param[i++].Size = 1000;
            param[i++].Size = 18;
            param[i++].Size = 10;
            param[i++].Size = 20;
            param[i++].Size = 50;
            param[i++].Size = 20;
            param[i++].Size = 50;
            param[i++].Size = 20;


            return(param);
        }
コード例 #10
0
        public bool GetSpecialReturnMaterialListByPage(ref List <SpecialReturnMaterial> modelList, SpecialReturnMaterial model, ref DividPage page, UserInfo user, ref string strError)
        {
            if (page == null)
            {
                page = new DividPage();
            }
            List <SpecialReturnMaterial> lstModel = new List <SpecialReturnMaterial>();

            try
            {
                using (SqlDataReader dr = Common_DB.QueryByDividPage(ref page, "V_SpecialReturnMaterial", GetFilterSql(model, user), "*", "Order By InvtID,ID Desc"))
                {
                    while (dr.Read())
                    {
                        lstModel.Add(GetModelFromDataReader(dr));
                    }
                }

                modelList = lstModel;
                return(true);
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
            finally
            {
            }
        }