//更新 public bool UpdRES_BANK(RES_BANKInfo info) { Database db = GetDatabase(); StringBuilder sbCmd = new StringBuilder(); sbCmd.AppendLine(" UPDATE RES_BANK "); sbCmd.AppendLine(" SET BANK_NAME = @BANK_NAME "); sbCmd.AppendLine(" ,TEL_NO = @TEL_NO "); sbCmd.AppendLine(" ,MAIL_1 = @MAIL_1 "); sbCmd.AppendLine(" ,MAIL_2 = @MAIL_2 "); sbCmd.AppendLine(" ,MAIL_3 = @MAIL_3 "); sbCmd.AppendLine(" ,Maker = @Maker "); sbCmd.AppendLine(" ,Maker_Time = @Maker_Time "); sbCmd.AppendLine(" ,Checker = @Checker "); sbCmd.AppendLine(" ,Checker_Time = @Checker_Time "); sbCmd.AppendLine(" WHERE BANK_CODE = @BANK_CODE "); DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString()); #region 指定參數 db.AddInParameter(dbCommand, "@BANK_CODE", DbType.String, info.BANK_CODE); db.AddInParameter(dbCommand, "@BANK_NAME", DbType.String, info.BANK_NAME); db.AddInParameter(dbCommand, "@TEL_NO", DbType.String, info.TEL_NO); db.AddInParameter(dbCommand, "@MAIL_1", DbType.String, info.MAIL_1); db.AddInParameter(dbCommand, "@MAIL_2", DbType.String, info.MAIL_2); db.AddInParameter(dbCommand, "@MAIL_3", DbType.String, info.MAIL_3); db.AddInParameter(dbCommand, "@Maker", DbType.String, info.Maker); db.AddInParameter(dbCommand, "@Maker_Time", DbType.DateTime, info.Maker_Time); db.AddInParameter(dbCommand, "@Checker", DbType.String, info.Maker); db.AddInParameter(dbCommand, "@Checker_Time", DbType.DateTime, info.Maker_Time); #endregion return(ExecuteNonQuery(db, dbCommand)); }
//新增 public bool InsRES_BANK(RES_BANKInfo info) { Database db = GetDatabase(); StringBuilder sbCmd = new StringBuilder(); sbCmd.AppendLine(" INSERT INTO RES_BANK "); sbCmd.AppendLine(" (BANK_CODE, BANK_NAME, TEL_NO, MAIL_1, MAIL_2, MAIL_3, Maker, Maker_Time, Checker, Checker_Time) "); sbCmd.AppendLine(" Values "); sbCmd.AppendLine(" (@BANK_CODE, @BANK_NAME, @TEL_NO, @MAIL_1, @MAIL_2, @MAIL_3, @Maker, @Maker_Time, @Checker, @Checker_Time) "); DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString()); #region 指定參數 db.AddInParameter(dbCommand, "@BANK_CODE", DbType.String, info.BANK_CODE); db.AddInParameter(dbCommand, "@BANK_NAME", DbType.String, info.BANK_NAME); db.AddInParameter(dbCommand, "@TEL_NO", DbType.String, info.TEL_NO); db.AddInParameter(dbCommand, "@MAIL_1", DbType.String, info.MAIL_1); db.AddInParameter(dbCommand, "@MAIL_2", DbType.String, info.MAIL_2); db.AddInParameter(dbCommand, "@MAIL_3", DbType.String, info.MAIL_3); db.AddInParameter(dbCommand, "@Maker", DbType.String, info.Maker); db.AddInParameter(dbCommand, "@Maker_Time", DbType.DateTime, info.Maker_Time); db.AddInParameter(dbCommand, "@Checker", DbType.String, info.Checker); db.AddInParameter(dbCommand, "@Checker_Time", DbType.DateTime, info.Checker_Time); #endregion //ExecuteNonQuery 傳回受影響的資料列數目 //也就是說要在新增 修改 刪除時 執行這一段 值才會傳回資料庫 //要是沒這一段就不會把要改變的數值傳回 return(ExecuteNonQuery(db, dbCommand)); }
public bool LoadBANKCODE(string iBANK_CODE, out RES_BANKInfo myInfo) { bool Result = false; //到db透過key值找編輯中的那筆資料 Database db = base.GetDatabase(); StringBuilder sbCmd = new StringBuilder(); sbCmd.AppendLine(" select * from RES_BANK with (nolock) "); sbCmd.AppendLine(" where BANK_CODE = @BANK_CODE "); DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString()); #region 指定參數 db.AddInParameter(dbCommand, "@BANK_CODE", DbType.String, iBANK_CODE); #endregion DataTable dtTemp = ExecuteDataSet(db, dbCommand).Tables[0]; //判斷找到的資料是否存在 if (dtTemp.Rows.Count == 0) { Result = false; //把info內的預設值給myinfo myInfo = new RES_BANKInfo(); } else { Result = true; //把info內已存在的dtTemp.Rows[0]值指定給myinfo myInfo = new RES_BANKInfo(dtTemp.Rows[0]); } return(Result); }
/// <summary> /// 將 info 的值填入到 UI 中 /// </summary> private void FillModFieldValue(RES_BANKInfo myInfo) { //資料狀態 lbModItem.Text = "修改"; //data fields txtiBANK_CODE.Text = myInfo.BANK_CODE; txtiBANK_NAME.Text = myInfo.BANK_NAME; txtiTEL_NO.Text = myInfo.TEL_NO; txtiMAIL_1.Text = myInfo.MAIL_1; txtiMAIL_2.Text = myInfo.MAIL_2; txtiMAIL_3.Text = myInfo.MAIL_3; }
//將UI上的值指定到Info中 //傳值呼叫方法 /* * private RES_BANKInfo GetModFieldValue() * { * RES_BANKInfo iInfo = new RES_BANKInfo(); * * //將值指定到Info中 * iInfo.BANK_CODE = txtiBANK_CODE.Text.Trim(); * iInfo.BANK_NAME = txtiBANK_NAME.Text.Trim(); * iInfo.TEL_NO = txtiTEL_NO.Text.Trim(); * iInfo.MAIL_1 = txtiMAIL_1.Text.Trim(); * iInfo.MAIL_2 = txtiMAIL_2.Text.Trim(); * iInfo.MAIL_3 = txtiMAIL_3.Text.Trim(); * iInfo.Maker_Time = DateTime.Now; * iInfo.Checker_Time = DateTime.Now; * * return iInfo; * * //將值指定到Info中 * * //if (!string.IsNullOrEmpty(txtiDisplayOrder.Text.Trim())) * // BuffInfo.DisplayOrder = Convert.ToInt32(txtiDisplayOrder.Text); * //else * // BuffInfo.DisplayOrder = 0; * * } */ //傳址呼叫方法 private void GetModFieldValue(out RES_BANKInfo iInfo) { iInfo = new RES_BANKInfo(); //將值指定到Info中 iInfo.BANK_CODE = txtiBANK_CODE.Text.Trim(); iInfo.BANK_NAME = txtiBANK_NAME.Text.Trim(); iInfo.TEL_NO = txtiTEL_NO.Text.Trim(); iInfo.MAIL_1 = txtiMAIL_1.Text.Trim(); iInfo.MAIL_2 = txtiMAIL_2.Text.Trim(); iInfo.MAIL_3 = txtiMAIL_3.Text.Trim(); iInfo.Maker_Time = DateTime.Now; iInfo.Checker_Time = DateTime.Now; }