private void dgvReaderType_SelectionChanged(object sender, EventArgs e) { if (dgvReaderType.CurrentCell == null) return; readertype= ReaderTypeAdmin.GetReaderType(Convert.ToString( dgvReaderType["rdType", dgvReaderType.CurrentCell.RowIndex].Value)); SetReaderTypeToText(); }
//添加复制函数 public ReaderType(ReaderType rt) { this.rdType = rt.rdType; this.rdTypeName = rt.rdTypeName; this.CanLendQty = rt.CanLendQty; this.CanLendDay = rt.CanLendDay; this.CanContinueTimes = rt.CanContinueTimes; this.PunishRate = rt.PunishRate; this.DateValid = rt.DateValid; }
//删除 public static int Delete(ReaderType readertype) { int rows = 0; string sql = "delete from ReaderType where rdType=@rdType"; SqlParameter[] parameters = { new SqlParameter("@rdType", readertype.rdType) }; try { rows = SqlHelper.ExecuteNonQuery(sql, parameters); } catch (SqlException ex) { throw new Exception(ex.Message); } return rows; }
//插入 public static int Insert(ReaderType readertype) { int rows = 0; string sql = "insert into ReaderType(rdType,rdTypeName,CanLendQty,CanLendDay,CanContinueTimes,PunishRate,DateValid)" + "values (@rdType,@rdTypeName,@CanLendQty,@CanLendDay,@CanContinueTimes,@PunishRate,@DateValid)"; SqlParameter[] parameters ={ new SqlParameter("@rdType",readertype.rdType), new SqlParameter("@rdTypeName",readertype.rdTypeName), new SqlParameter("@CanLendQty",readertype.CanLendQty), new SqlParameter("@CanLendDay",readertype.CanLendDay), new SqlParameter("@CanContinueTimes",readertype.CanContinueTimes), new SqlParameter("@PunishRate",readertype.PunishRate), new SqlParameter("@DateValid",readertype.DateValid) }; try { rows = SqlHelper.ExecuteNonQuery(sql, parameters); } catch(SqlException ex) { throw new Exception(ex.Message); } return rows; }
//更新 public static int Update(ReaderType readertype) { int rows = 0; string sql = "update ReaderType set " + "rdType=@rdType," + "rdTypeName=@rdTypeName," + "CanLendQty=@CanLendQty," + "CanLendDay=@CanLendDay," + "CanContinueTimes=@CanContinueTimes," + "PunishRate=@PunishRate," + "DateValid=@DateValid " + "where rdType=@rdType"; SqlParameter[] parameters ={ new SqlParameter("@rdType",readertype.rdType), new SqlParameter("@rdTypeName",readertype.rdTypeName), new SqlParameter("@CanLendQty",readertype.CanLendQty), new SqlParameter("@CanLendDay",readertype.CanLendDay), new SqlParameter("@CanContinueTimes",readertype.CanContinueTimes), new SqlParameter("@PunishRate",readertype.PunishRate), new SqlParameter("@DateValid",readertype.DateValid) }; try { rows = SqlHelper.ExecuteNonQuery(sql, parameters); } catch (SqlException ex) { throw new Exception(ex.Message); } return rows; }