private void btn_add_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tb_name.Text)) { MessageBox.Show("请填写姓名!"); } if (string.IsNullOrEmpty(tb_phone.Text)) { MessageBox.Show("请填写手机号!"); } string sex = "1"; if (rb_woman.Checked) { sex = "2"; } string sql = "INSERT INTO Info(name,sex,phone,company,positions,address,creationtime,state) "; sql += $"VALUES ('{tb_name.Text}','{sex}','{tb_phone.Text}','{tb_company.Text}','{tb_position.Text}','{tb_address.Text}','{DateTime.Now}','0') "; int res = DbHelperACE.ExecuteSql(sql); if (res > 0) { MessageBox.Show("新增成功!"); } }
private List <People> GetPeoples(string name = "", int Id = 0) { string sql = "select * from Info where state='0' "; if (Id != 0) { sql += "and id=" + Id; } if (!string.IsNullOrEmpty(name)) { sql += "and name like '%" + name + "%' or company like '%" + name + "%'"; } DataSet info = DbHelperACE.Query(sql); List <People> peoples = new List <People>(); if (info.Tables.Count >= 1) { DataTable dt = info.Tables[0]; foreach (DataRow var in dt.Rows) { peoples.Add(Peoples(var)); } } return(peoples); }
private void btn_updata_Click(object sender, EventArgs e) { string sql = $"UPDATE Info SET phone='{tb_phone.Text}', company='{tb_company.Text}', positions='{tb_position.Text}', address='{tb_address.Text}' WHERE id = {Id}"; int res = DbHelperACE.ExecuteSql(sql); if (res > 0) { MessageBox.Show("修改成功!"); } }
private void btn_del_Click(object sender, EventArgs e) { string sql = $"UPDATE Info SET state = '1' WHERE id = {Id}"; int res = DbHelperACE.ExecuteSql(sql); if (res > 0) { MessageBox.Show("删除成功!"); } }
public static int GetMaxID(string FieldName, string TableName) { string strsql = "select max(" + FieldName + ")+1 from " + TableName; object obj = DbHelperACE.GetSingle(strsql); if (obj == null) { return(1); } else { return(int.Parse(obj.ToString())); } }
public static int GetRecordCount(string _ID, string _tbName, string _strCondition, int _Dist) { string sql = getPageListCounts(_ID, _tbName, _strCondition, _Dist); object obj = DbHelperACE.GetSingle(sql); if (obj == null) { return(1); } else { return(int.Parse(obj.ToString())); } }
private List <People> GetPeoples(string Id) { string sql = "select * from Info where state='0' and id=" + Id; DataSet info = DbHelperACE.Query(sql); List <People> peoples = new List <People>(); if (info.Tables.Count >= 1) { DataTable dt = info.Tables[0]; foreach (DataRow var in dt.Rows) { peoples.Add(Peoples(var)); } } return(peoples); }
public static bool Exists(string strSql, params OleDbParameter[] cmdParms) { object obj = DbHelperACE.GetSingle(strSql, cmdParms); int cmdresult; if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(obj.ToString()); } if (cmdresult == 0) { return(false); } else { return(true); } }