private static HA_ArgGroup ToModel(DataRow row) { HA_ArgGroup model = new HA_ArgGroup(); model.ag_name = row.IsNull("ag_name") ? null : (String)row["ag_name"]; model.ag_code = row.IsNull("ag_code") ? null : (String)row["ag_code"]; model.ag_paras = row.IsNull("ag_paras") ? null : (String)row["ag_paras"]; model.ag_note = row.IsNull("ag_note") ? null : (String)row["ag_note"]; return(model); }
public bool Update(HA_ArgGroup model) { string sqlStr = "update HA_ArgGroup set ag_name=@ag_name,ag_code=@ag_code,ag_paras=@ag_paras,ag_note=@ag_note where ag_code=@ag_code"; int rows = SQLHelper.ExecuteNonQuery(sqlStr , new SqlParameter("ag_name", model.ag_name) , new SqlParameter("ag_code", model.ag_code) , new SqlParameter("ag_paras", model.ag_paras) , new SqlParameter("ag_note", model.ag_note) ); return(rows > 0); }
public int AddNew(HA_ArgGroup model) { string sqlStr = "insert into HA_ArgGroup(ag_name,ag_code,ag_paras,ag_note) output inserted.ag_id values(@ag_name,@ag_code,@ag_paras,@ag_note)"; int id = (int)SQLHelper.ExecuteScalar(sqlStr , new SqlParameter("ag_name", model.ag_name) , new SqlParameter("ag_code", model.ag_code) , new SqlParameter("ag_paras", model.ag_paras) , new SqlParameter("ag_note", model.ag_note) ); return(id); }
public HA_ArgGroup GetModelById(string id) { string sqlStr = "select * from HA_ArgGroup where ag_code=@id"; DataTable dt = SQLHelper.ExecuteDataTable(sqlStr, new SqlParameter("id", id)); if (dt.Rows.Count > 1) { throw new Exception("more than 1 row was found"); } if (dt.Rows.Count <= 0) { return(null); } DataRow row = dt.Rows[0]; HA_ArgGroup model = ToModel(row); return(model); }
private void listVAGs_DoubleClick(object sender, EventArgs e) { if (listVAGs.SelectedItems.Count > 0) { var a = listVAGs.SelectedItems[0]; HA_ArgGroup ha_ag = new HA_ArgGroup { ag_code = a.SubItems[0].Text, ag_name = a.SubItems[1].Text, ag_paras = a.SubItems[2].Text, ag_note = a.SubItems[3].Text }; FrmManageAG agForm = new FrmManageAG(ha_ag); agForm.ShowDialog(); ReloadAGs(); } }
public FrmManageAG(HA_ArgGroup ha_ag) { agobj = ha_ag; InitializeComponent(); }