예제 #1
0
        public bool GetCheckListByPage(ref List <CheckInfo> modelList, CheckInfo model, ref DividPage page, UserInfo user, ref string strError)
        {
            if (page == null)
            {
                page = new DividPage();
            }
            List <CheckInfo> lstModel = new List <CheckInfo>();

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

                modelList = lstModel;
                return(true);
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
            finally
            {
            }
        }
예제 #2
0
        private SqlParameter[] GetParameterFromModel(CheckInfo model)
        {
            int i;

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

                new SqlParameter("@v_ID", model.ID.ToSqlValue()),
                new SqlParameter("@v_CheckObj", model),
                //new SqlParameter("@v_lstCheckDetail", model.lstDetails.ToArray()),
                new SqlParameter("@v_CreateTime", model.CreateTime.ToSqlValue()),
                new SqlParameter("@v_ModifyTime", model.ModifyTime.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.InputOutput;
            param[i++].Direction = ParameterDirection.InputOutput;

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

            param[2].UdtTypeName = "CheckInfo";
            param[3].UdtTypeName = "CheckDetailsInfo_List";

            param[2].SqlDbType = SqlDbType.Object;
            param[3].SqlDbType = SqlDbType.Array;

            return(param);
        }
예제 #3
0
 public bool GetCheckByID(ref CheckInfo model, UserInfo user, ref string strError)
 {
     try
     {
         using (SqlDataReader dr = _db.GetCheckByID(model))
         {
             if (dr.Read())
             {
                 model = (GetModelFromDataReader(dr));
                 return(true);
             }
             else
             {
                 strError = "找不到任何数据";
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
     finally
     {
     }
 }
예제 #4
0
        private CheckInfo GetModelFromDataReader(SqlDataReader dr)
        {
            CheckInfo model = new CheckInfo();

            model.ID          = dr["ID"].ToInt32();
            model.CheckNo     = dr["CheckNo"].ToDBString();
            model.CheckType   = dr["CheckType"].ToInt32();
            model.DutyUser    = dr["DutyUser"].ToDBString();
            model.CheckDesc   = dr["CheckDesc"].ToDBString();
            model.CheckStatus = dr["CheckStatus"].ToInt32();
            model.BeginTime   = dr["BeginTime"].ToDateTimeNull();
            model.DoneTime    = dr["DoneTime"].ToDateTimeNull();
            model.Remarks     = dr["Remarks"].ToDBString();
            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();

            if (Common_Func.readerExists(dr, "StrCheckType"))
            {
                model.StrCheckType = dr["StrCheckType"].ToDBString();
            }
            if (Common_Func.readerExists(dr, "StrCheckStatus"))
            {
                model.StrCheckStatus = dr["StrCheckStatus"].ToDBString();
            }

            model.EditText = model.CheckStatus == 1 ? "编辑" : "查看";

            return(model);
        }
예제 #5
0
        public SqlDataReader GetCheckByID(CheckInfo model)
        {
            string strSql = string.Empty;

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

            return(OperationSql.ExecuteReader(CommandType.Text, strSql, null));
        }
예제 #6
0
 public bool DeleteCheckByID(CheckInfo model, UserInfo user, ref string strError)
 {
     try
     {
         return(_db.DeleteCheckByID(model));
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
예제 #7
0
        public bool SaveCheck(ref CheckInfo model)
        {
            SqlParameter[] param = GetParameterFromModel(model);

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

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

            if (ErrorMsg.StartsWith("执行错误"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                model.ID = param[1].Value.ToInt32();
                return(true);
            }
        }
예제 #8
0
 public bool SaveCheck(ref CheckInfo model, UserInfo user, ref string strError)
 {
     try
     {
         if (model.ID <= 0)
         {
             model.Creater = user.UserNo;
         }
         else
         {
             model.Modifyer = user.UserNo;
         }
         return(_db.SaveCheck(ref model));
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
예제 #9
0
        public bool DeleteCheckByID(CheckInfo 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_DeleteCheckByID", param);

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

            if (ErrorMsg.StartsWith("执行错误"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                return(true);
            }
        }
예제 #10
0
        private string GetFilterSql(CheckInfo model, UserInfo user)
        {
            try
            {
                string strSql   = " Where NVL(IsDel,1) = 1 ";
                bool   hadWhere = true;


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

                if (model.CheckType >= 1)
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " CheckType = " + model.CheckType + " ";
                    hadWhere = true;
                }

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

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

                if (model.CheckStatus >= 1)
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " CheckStatus = " + model.CheckStatus + " ";
                    hadWhere = true;
                }

                if (!string.IsNullOrEmpty(model.Remarks))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " Remarks Like '%" + model.Remarks + "%' ";
                    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);
            }
        }