public bool GetPreparationByID(ref Preparation model, UserInfo user, ref string strError) { try { using (SqlDataReader dr = _db.GetPreparationByID(model)) { if (dr.Read()) { model = (GetModelFromDataReader(dr)); return(true); } else { strError = "找不到任何数据"; return(false); } } } catch (Exception ex) { strError = ex.Message; return(false); } finally { } }
public bool GetPreparationListByPage(ref List <Preparation> modelList, Preparation model, ref DividPage page, UserInfo user, ref string strError) { if (page == null) { page = new DividPage(); } List <Preparation> lstModel = new List <Preparation>(); try { using (SqlDataReader dr = Common_DB.QueryByDividPage(ref page, "V_Preparation", GetFilterSql(model, user), "*", "Order By pCode,ID Desc")) { while (dr.Read()) { lstModel.Add(GetModelFromDataReader(dr)); } } modelList = lstModel; return(true); } catch (Exception ex) { strError = ex.Message; return(false); } finally { } }
public SqlDataReader GetPreparationByID(Preparation model) { string strSql = string.Empty; strSql = string.Format("SELECT * FROM V_Preparation WHERE ID = {0}", model.ID); return(OperationSql.ExecuteReader(CommandType.Text, strSql, null)); }
public bool DeletePreparationByID(Preparation model, UserInfo user, ref string strError) { try { return(_db.DeletePreparationByID(model)); } catch (Exception ex) { strError = ex.Message; return(false); } }
public bool ExistspCode(Preparation model, bool bIncludeDel, UserInfo user, ref string strError) { try { return(_db.ExistspCode(model, bIncludeDel)); } catch (Exception ex) { strError = ex.Message; return(false); } }
private string GetFilterSql(Preparation model, UserInfo user) { try { string strSql = " Where ISNULL(IsDel,1) = 1 "; bool hadWhere = true; if (!string.IsNullOrEmpty(model.pCode)) { strSql = Common_Func.AddWhereAnd(strSql, hadWhere); strSql += " (pCode LIKE '%" + model.pCode + "%' OR pName Like '%" + model.pCode + "%') "; 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); } }
private Preparation GetModelFromDataReader(SqlDataReader dr) { Preparation model = new Preparation(); model.ID = dr["ID"].ToInt32(); model.pCode = dr["pCode"].ToDBString(); model.pName = dr["pName"].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(); model.bid = dr["bid"].ToInt32(); return(model); }
private SqlParameter[] GetParameterFromModel(Preparation model) { int i; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000), new SqlParameter("@v_ID", model.ID.ToSqlValue()), new SqlParameter("@v_pCode", model.pCode.ToSqlValue()), new SqlParameter("@v_pName", model.pName.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_bid", model.bid.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.Output; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Output; param[i++].Direction = ParameterDirection.Input; i = 0; param[i++].Size = 1000; param[i++].Size = 18; param[i++].Size = 20; param[i++].Size = 50; param[i++].Size = 18; param[i++].Size = 18; param[i++].Size = 18; param[i++].Size = 18; param[i++].Size = 18; param[i++].Size = 18; return(param); }
public bool SavePreparation(ref Preparation model, UserInfo user, ref string strError) { try { if (model.ID <= 0) { model.Creater = user.UserNo; } else { model.Modifyer = user.UserNo; } return(_db.SavePreparation(ref model)); } catch (Exception ex) { strError = ex.Message; return(false); } }
public bool SavePreparation(ref Preparation model) { SqlParameter[] param = GetParameterFromModel(model); OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_SavePreparation", param); string ErrorMsg = param[0].Value.ToDBString(); if (ErrorMsg.StartsWith("执行错误")) { 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); } }
public bool DeletePreparationByID(Preparation 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_DeletePreparationByID", param); string ErrorMsg = param[0].Value.ToDBString(); if (ErrorMsg.StartsWith("执行错误")) { throw new Exception(ErrorMsg); } else { return(true); } }
public bool GetPreparationList(ref List <Preparation> modelList, Preparation model, UserInfo user, ref string strError) { List <Preparation> lstModel = new List <Preparation>(); try { using (SqlDataReader dr = Common_DB.QueryAll("V_Preparation", GetFilterSql(model, user), "*", "Order By pCode,ID Desc")) { while (dr.Read()) { lstModel.Add(GetModelFromDataReader(dr)); } } modelList = lstModel; return(true); } catch (Exception ex) { strError = ex.Message; return(false); } }
public bool ExistspCode(Preparation model, bool bIncludeDel) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000), new SqlParameter("@v_pCode", model.pCode.ToSqlValue()), new SqlParameter("@IncludeDel", bIncludeDel.ToSqlValue()), }; param[0].Direction = ParameterDirection.Output; OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_ExistspCode", param); string ErrorMsg = param[0].Value.ToDBString(); if (ErrorMsg.StartsWith("执行错误")) { throw new Exception(ErrorMsg); } else { return(string.IsNullOrEmpty(ErrorMsg)); } }