예제 #1
0
파일: DbHelperTools.cs 프로젝트: pcstx/OA
 /// <summary>
 /// 新增信息
 /// </summary>
 /// <param name="_PSACNEntity"></param>
 /// <returns>返回string "-1"表示该已经存在,否则成功 </returns>
 public string AddPSACN(PSACNEntity _PSACNEntity)
 {
     //判断该记录是否已经存在
     DbParameter[] prams = {MakeInParam("@PSACNCO",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNCO),
                              };
     string sql = "select * from PSACN where PSACNCO=@PSACNCO";
     if (ExecuteDataset(CommandType.Text, sql, prams).Tables[0].Rows.Count > 0)
     {
         return "-1";//该记录已经存在
     }
     else
     {
         DbParameter[] pramsInsert = {
                               MakeInParam("@PSACNCO",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNCO ),
                               MakeInParam("@PSACNNCN",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNNCN ),
                               MakeInParam("@PSACNNEN",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNNEN ),
                               MakeInParam("@PSACNNTW",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNNTW ),
                               MakeInParam("@PSACNPRE",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNPRE ),
                               MakeInParam("@PSACNDAT",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNDAT ),
                               MakeInParam("@PSACNLEN",(DbType)SqlDbType.Int,4,_PSACNEntity.PSACNLEN ),
                               MakeInParam("@PSACNCUR",(DbType)SqlDbType.Int,4,_PSACNEntity.PSACNCUR ),
                               MakeInParam("@PSACNPDA",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNPDA ),
                                      };
         StringBuilder sb = new StringBuilder();
         sb.Append("INSERT INTO [dbo].[PSACN]");
         sb.Append("(");
         sb.Append("[PSACNCO]");
         sb.Append(",[PSACNNCN]");
         sb.Append(",[PSACNNEN]");
         sb.Append(",[PSACNNTW]");
         sb.Append(",[PSACNPRE]");
         sb.Append(",[PSACNDAT]");
         sb.Append(",[PSACNLEN]");
         sb.Append(",[PSACNCUR]");
         sb.Append(",[PSACNPDA]");
         sb.Append(") ");
         sb.Append("VALUES ");
         sb.Append("(@PSACNCO,");
         sb.Append("@PSACNNCN,");
         sb.Append("@PSACNNEN,");
         sb.Append("@PSACNNTW,");
         sb.Append("@PSACNPRE,");
         sb.Append("@PSACNDAT,");
         sb.Append("@PSACNLEN,");
         sb.Append("@PSACNCUR,");
         sb.Append("@PSACNPDA)");
         sb.Append("select @@identity;");
         return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString();
     }
 }
예제 #2
0
파일: DbHelperTools.cs 프로젝트: pcstx/OA
 private PSACNEntity GetPSACNFromIDataReader(DbDataReader dr)
 {
     PSACNEntity dt = new PSACNEntity();
     if (dr.FieldCount > 0)
     {
         dt.PSACNCO = dr["PSACNCO"].ToString();
         dt.PSACNNCN = dr["PSACNNCN"].ToString();
         dt.PSACNNEN = dr["PSACNNEN"].ToString();
         dt.PSACNNTW = dr["PSACNNTW"].ToString();
         dt.PSACNPRE = dr["PSACNPRE"].ToString();
         dt.PSACNDAT = dr["PSACNDAT"].ToString();
         if (dr["PSACNLEN"].ToString() != "" || dr["PSACNLEN"] != null) dt.PSACNLEN = Int32.Parse(dr["PSACNLEN"].ToString());
         if (dr["PSACNCUR"].ToString() != "" || dr["PSACNCUR"] != null) dt.PSACNCUR = Int32.Parse(dr["PSACNCUR"].ToString());
         dt.PSACNPDA = dr["PSACNPDA"].ToString();
         dr.Close();
         return dt;
     }
     dr.Close();
     return null;
 }
예제 #3
0
파일: DbHelperTools.cs 프로젝트: pcstx/OA
 /// <summary>
 /// 修改信息
 /// </summary>
 /// <param name="_PSACNEntity"></param>
 /// <returns>返回string "-1"表示该已经存在,否则成功 </returns>
 public string UpdatePSACN(PSACNEntity _PSACNEntity)
 {
     DbParameter[] pramsUpdate = {
                               MakeInParam("@PSACNCO",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNCO ),
                               MakeInParam("@PSACNNCN",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNNCN ),
                               MakeInParam("@PSACNNEN",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNNEN ),
                               MakeInParam("@PSACNNTW",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNNTW ),
                               MakeInParam("@PSACNPRE",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNPRE ),
                               MakeInParam("@PSACNDAT",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNDAT ),
                               MakeInParam("@PSACNLEN",(DbType)SqlDbType.Int,4,_PSACNEntity.PSACNLEN ),
                               MakeInParam("@PSACNCUR",(DbType)SqlDbType.Int,4,_PSACNEntity.PSACNCUR ),
                               MakeInParam("@PSACNPDA",(DbType)SqlDbType.VarChar,50,_PSACNEntity.PSACNPDA ),
                                      };
     StringBuilder sb = new StringBuilder();
     sb.Append("Update [dbo].[PSACN]");
     sb.Append(" set ");
     sb.Append(" [PSACNNCN]=@PSACNNCN,");
     sb.Append(" [PSACNNEN]=@PSACNNEN,");
     sb.Append(" [PSACNNTW]=@PSACNNTW,");
     sb.Append(" [PSACNPRE]=@PSACNPRE,");
     sb.Append(" [PSACNDAT]=@PSACNDAT,");
     sb.Append(" [PSACNLEN]=@PSACNLEN,");
     sb.Append(" [PSACNCUR]=@PSACNCUR,");
     sb.Append(" [PSACNPDA]=@PSACNPDA");
     sb.Append(" where [PSACNCO]=@PSACNCO");
     sb.Append(" select @PSACNCO");
     return ExecuteScalar(CommandType.Text, sb.ToString(), pramsUpdate).ToString();
 }