public static int Delete(Sqlite lit, int id) { lit.ExcSql(string.Format("delete from t_ApiDb where fapiid={0}", id)); lit.ExcSql(string.Format("delete from t_ApiParam where fapiid={0}", id)); lit.ExcSql(string.Format("delete from t_ApiRight where fapiid={0}", id)); return(lit.ExcSql(string.Format("delete from t_Api where fid={0}", id))); }
private void btnDel_Click(object sender, System.EventArgs e) { int id = (int)dgData.Rows[dgData.SelectedCells[0].RowIndex].Cells[0].Value; string number = dgData.Rows[dgData.SelectedCells[0].RowIndex].Cells[0].Value.ToString(); DialogResult dr = MessageBox.Show(string.Format("确认删除'{0}'?", number), "提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { lit.ExcSql(string.Format("delete from t_Api where fid={0}", id)); lit.ExcSql(string.Format("delete from t_ApiDb where fapiid={0}", id)); lit.ExcSql(string.Format("delete from t_ApiParam where fapiid={0}", id)); lit.ExcSql(string.Format("delete from t_ApiRight where fapiid={0}", id)); refreshData(); } }
public frmDbMgr() { InitializeComponent(); lit = new xl_rp.Sqlite(); dgData.ColumnCount = 5; dgData.ColumnHeadersVisible = true; dgData.Columns[0].Name = "id"; dgData.Columns[0].DataPropertyName = "fid"; dgData.Columns[0].HeaderText = "id"; dgData.Columns[0].Visible = false; dgData.Columns[1].DataPropertyName = "fnumber"; dgData.Columns[1].HeaderText = "编号"; dgData.Columns[2].DataPropertyName = "fname"; dgData.Columns[2].HeaderText = "名称"; dgData.Columns[3].DataPropertyName = "ftype"; dgData.Columns[3].HeaderText = "类型"; dgData.Columns[4].DataPropertyName = "fstrconn"; dgData.Columns[4].HeaderText = "链接字符串"; DataTable dt = lit.GetDataTable("select * from sqlite_master where name='t_db'"); if (dt.Rows.Count <= 0) { lit.ExcSql("create table t_db(fid int,fnumber varchar(255),fname varchar(255),ftype varchar(255),fstrconn varchar(1024))"); } refreshData(); }
public frmUserMgr() { InitializeComponent(); lit = new xl_rp.Sqlite(); dgData.ColumnCount = 3; dgData.ColumnHeadersVisible = true; dgData.Columns[0].Name = "id"; dgData.Columns[0].DataPropertyName = "fid"; dgData.Columns[0].HeaderText = "id"; dgData.Columns[0].Visible = false; dgData.Columns[1].DataPropertyName = "fnumber"; dgData.Columns[1].HeaderText = "编号"; dgData.Columns[2].DataPropertyName = "fname"; dgData.Columns[2].HeaderText = "名称"; DataTable dt = lit.GetDataTable("select * from sqlite_master where name='t_user'"); if (dt.Rows.Count <= 0) { lit.ExcSql("create table t_user(fid int,fnumber varchar(255),fname varchar(255),fpsw varchar(255))"); } refreshData(); }
public int Save(Sqlite lit) { number = number.Trim(); name = name.Trim(); if (string.IsNullOrEmpty(number)) { throw new Exception("编号不能为空"); } if (string.IsNullOrEmpty(name)) { throw new Exception("名称不能为空"); } if (string.IsNullOrEmpty(type)) { throw new Exception("数据库类型不能为空"); } if (string.IsNullOrEmpty(strConn)) { throw new Exception("链接字符串不能为空"); } DataTable dt = lit.GetDataTable(string.Format("select * from t_db where fid<>{0} and fnumber='{1}'", id, number)); if (dt.Rows.Count > 0) { throw new Exception(string.Format("已存在编号为'{0}'的记录", number)); } int recCnt = 0; if (id == 0) { dt = lit.GetDataTable("select max(fid) id from t_db"); if (dt.Rows.Count <= 0) { id = 1; } else { id = (dt.Rows[0]["id"].ToString() == "" ? 0 : int.Parse(dt.Rows[0]["id"].ToString())) + 1; } recCnt = lit.ExcSql(string.Format("insert into t_db(fid,fnumber,fname,ftype,fstrconn) values({0},'{1}','{2}','{3}','{4}')", id, number, name, type, strConn)); } else { recCnt = lit.ExcSql(string.Format("update t_db set fnumber='{1}',fname='{2}',ftype='{3}',fstrconn='{4}' where fid={0}", id, number, name, type, strConn)); } return(recCnt); }
public int Save(Sqlite lit) { if (string.IsNullOrEmpty(number)) { throw new System.Exception("编号不能为空"); } if (string.IsNullOrEmpty(name)) { throw new Exception("名称不能为空"); } number = number.Trim(); name = name.Trim(); DataTable dt = lit.GetDataTable(string.Format("select * from t_Api where fid<>{0} and fnumber='{1}'", id, number)); if (dt.Rows.Count > 0) { throw new Exception(string.Format("已存在编号为'{0}'的记录", number)); } int recCnt = 0; if (id == 0) { dt = lit.GetDataTable("select max(fid) id from t_Api"); if (dt.Rows.Count <= 0) { id = 1; } else { id = (dt.Rows[0]["id"].ToString() == "" ? 0 : int.Parse(dt.Rows[0]["id"].ToString())) + 1; } recCnt = lit.ExcSql(string.Format("insert into t_Api(fid,fnumber,fname,fnote) values({0},'{1}','{2}','{3}')", id, number, name, note)); } else { recCnt = lit.ExcSql(string.Format("update t_Api set fnumber='{1}',fname='{2}',fnote='{3}' where fid={0}", id, number, name, note)); } lit.ExcSql(string.Format("delete from t_ApiParam where fapiid={0}", id)); foreach (ApiParam ap in param) { lit.ExcSql(string.Format("insert into t_ApiParam(fapiid,fname,fkey,fdefval,fnote) values({0},'{1}','{2}','{3}','{4}')", id, ap.name, ap.key, ap.defValue, ap.note)); } lit.ExcSql(string.Format("delete from t_ApiRight where fapiid={0}", id)); foreach (User u in right) { lit.ExcSql(string.Format("insert into t_ApiRight(fapiid,fuserid) values({0},'{1}')", id, u.id)); } lit.ExcSql(string.Format("delete from t_ApiDb where fapiid={0}", id)); foreach (ApiDb ad in db) { lit.ExcSql(string.Format("insert into t_ApiDb(fapiid,fdbid,fstrsql) values({0},'{1}','{2}')", id, ad.db.id, ad.strSql.Replace("'", "''"))); } return(recCnt); }
public frmApiMgr() { InitializeComponent(); lit = new xl_rp.Sqlite(); dgData.ColumnCount = 4; dgData.ColumnHeadersVisible = true; dgData.Columns[0].Name = "id"; dgData.Columns[0].DataPropertyName = "fid"; dgData.Columns[0].HeaderText = "id"; dgData.Columns[0].Visible = false; dgData.Columns[1].DataPropertyName = "fnumber"; dgData.Columns[1].HeaderText = "编号"; dgData.Columns[2].DataPropertyName = "fname"; dgData.Columns[2].HeaderText = "名称"; dgData.Columns[3].DataPropertyName = "fnote"; dgData.Columns[3].HeaderText = "备注"; DataTable dt = lit.GetDataTable("select * from sqlite_master where name='t_Api'"); if (dt.Rows.Count <= 0) { lit.ExcSql("create table t_Api(fid int,fnumber varchar(255),fname varchar(255),fnote varchar(8000))"); } dt = lit.GetDataTable("select * from sqlite_master where name='t_ApiDb'"); if (dt.Rows.Count <= 0) { lit.ExcSql("create table t_ApiDb(fapiid int,fdbid int,fstrsql varchar(8000))"); } dt = lit.GetDataTable("select * from sqlite_master where name='t_ApiParam'"); if (dt.Rows.Count <= 0) { lit.ExcSql("create table t_ApiParam(fapiid int,fname varchar(255),fkey varchar(255),fdefval varchar(255),fnote varchar(8000))"); } dt = lit.GetDataTable("select * from sqlite_master where name='t_ApiRight'"); if (dt.Rows.Count <= 0) { lit.ExcSql("create table t_ApiRight(fuserid int,fapiid int)"); } refreshData(); }
public static int Delete(Sqlite lit, int id) { return(lit.ExcSql(string.Format("delete from t_db where fid={0}", id))); }