/// <summary> /// 查询更新记录列表 /// </summary> /// <param name="sqls"></param> /// <returns></returns> public ArrayList getUpdateVersionList(string sqls) { SqlDataReader drs = null; ArrayList updatelist = new ArrayList(); try { drs = dg.executequery(sqls); while (drs.Read()) { UpdateVersionobj updateobj = new UpdateVersionobj(); updateobj.id = Convert.ToInt32(drs["id"]); updateobj.version = drs["version"].ToString(); updateobj.updatetime = drs["updatetime"].ToString(); updateobj.updatecontent = drs["updatecontent"].ToString(); updateobj.isfabu = Convert.ToInt32(drs["isfabu"]); updatelist.Add(updateobj); } } catch (Exception ex) { MessageBox.Show("统计异常", "软件提示"); throw ex; } finally { drs.Close(); dg.con_close(); } return(updatelist); }
/// <summary> /// 查询一般护理记录单记录 /// </summary> /// <param name="sqls"></param> /// <returns></returns> public UpdateVersionobj getUpdateVersionobj(string sqls) { DateLogic dg = new DateLogic(); SqlDataReader drs = null; try { drs = dg.executequery(sqls); UpdateVersionobj updateobj = null; if (!drs.HasRows) { return(null); } else { drs.Read();//读取第一行数据记录 updateobj = new UpdateVersionobj(); updateobj.id = Convert.ToInt32(drs["id"]); updateobj.version = drs["version"].ToString(); updateobj.updatetime = drs["updatetime"].ToString(); updateobj.updatecontent = drs["updatecontent"].ToString(); updateobj.isfabu = Convert.ToInt32(drs["isfabu"]); } return(updateobj); } catch (Exception ex) { MessageBox.Show("系统异常,请联系管理员", "软件提示"); throw ex; } }
private void button4_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { if (dataGridView1.SelectedRows[0].Tag != "") { UpdateVersionobj versionobj = dataGridView1.SelectedRows[0].Tag as UpdateVersionobj; if (MessageBox.Show("删除所选的记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; try { string sqls = "delete from updateversion where id=" + versionobj.id + ""; if (bll.deleterecord(sqls) > 0) { RefreshRecordList(); } else { MessageBox.Show("删除失败!", "请联系管理员"); } } finally { Cursor.Current = Cursors.Default; } } } } else { MessageBox.Show("请选择要的删除的行!", "系统提示"); } }
private string getUpdateSql(UpdateVersionobj versionobj) { StringBuilder sb = new StringBuilder(); sb.Append(" update updateversion set "); sb.Append(" version = '" + versionobj.version + "'"); sb.Append(" ,updatecontent = '" + versionobj.updatecontent + "'"); sb.Append(" where id=" + versionobj.id); return(sb.ToString()); }
private void button5_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { if (dataGridView1.SelectedRows[0].Tag != "") { UpdateVersionobj versionobj = dataGridView1.SelectedRows[0].Tag as UpdateVersionobj; //if (MessageBox.Show("确定要上传更新包吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) //{ Cursor.Current = Cursors.WaitCursor; OpenFileDialog filename = new OpenFileDialog(); filename.InitialDirectory = Application.StartupPath; filename.Filter = "压缩文件|*.zip"; filename.RestoreDirectory = true; if (filename.ShowDialog() == DialogResult.OK) { string path = filename.FileName.ToString(); //string name = path.Substring(path.LastIndexOf("\\")+1); //保存文件到SQL Server数据库中 FileInfo fi = new FileInfo(path); FileStream fs = fi.OpenRead(); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, Convert.ToInt32(fs.Length)); DateLogic dg = new DateLogic(); SqlConnection con = dg.getconn(); SqlCommand cm = new SqlCommand("update updateversion set updateprogram =@updateprogram,updatetime=@updatetime where id=@id", con); SqlParameter spFile = new SqlParameter("@updateprogram", SqlDbType.Image); SqlParameter spupdatetime = new SqlParameter("@updatetime", SqlDbType.Char); SqlParameter spid = new SqlParameter("@id", SqlDbType.Char); spFile.Value = bytes; spupdatetime.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); spid.Value = versionobj.id; cm.Parameters.Add(spFile); cm.Parameters.Add(spupdatetime); cm.Parameters.Add(spid); cm.ExecuteNonQuery(); RefreshRecordList(); } //} } } else { MessageBox.Show("请选择要上传的版本!", "系统提示"); } }
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { UpdateVersionobj versionobj = dataGridView1.Rows[e.RowIndex].Tag as UpdateVersionobj; versionobj.version = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); versionobj.updatecontent = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); string sqls = getUpdateSql(versionobj); if (bll.updaterecord(sqls) > 0) { //RefreshRecordList(); } else { MessageBox.Show("保存失败"); } }
private void button6_Click(object sender, EventArgs e) { SqlDataReader dr = null; if (dataGridView1.SelectedRows.Count > 0) { if (dataGridView1.SelectedRows[0].Tag != "") { UpdateVersionobj versionobj = dataGridView1.SelectedRows[0].Tag as UpdateVersionobj; if (String.IsNullOrEmpty(versionobj.updatetime)) { MessageBox.Show("请先上传更新包"); return; } if (String.IsNullOrEmpty(versionobj.version)) { MessageBox.Show("请填写该更新包的版本号"); return; } if (MessageBox.Show("确定要发布该更新吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { string updatestr = "update updateversion set isfabu=0 where id!=" + versionobj.id + ";update updateversion set isfabu=1 where id=" + versionobj.id; if (bll.updaterecord(updatestr) > 0) { MessageBox.Show("发布成功"); RefreshRecordList(); } else { MessageBox.Show("发布失败"); } } } } }