private void btnSave_Click(object sender, EventArgs e) { string sSql = ""; ArrayList lstSql = new ArrayList(); DataTable dtChanges = m_viewTagValue.Table.GetChanges(); if (dtChanges != null) { if (Program.frm1.PWDCheck("rg")) { foreach (DataRow row in dtChanges.Rows) { sSql = "update tags set unit='" + row["unit"] + "', SetValue=" + row["SetValue"].ToString() + "where [id]=" + row["id"].ToString(); lstSql.Add(sSql); } try { SQLHelper.ExecuteSql(lstSql); m_viewTagValue.Table.AcceptChanges(); if (this.UnitNO == 5) { FTableTags.setFill(); } else if (this.UnitNO == 6) { STableTags.setFill(); } MessageBox.Show("保存成功!"); this.Close(); } catch { m_viewTagValue.Table.RejectChanges(); MessageBox.Show("保存失败!"); } } else { MessageBox.Show("密码错误!"); } } else { MessageBox.Show("数据未改变!"); this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { string sSql = ""; ArrayList lstSql = new ArrayList(); DataTable dtChanges = m_viewTagValue.Table.GetChanges(); if (dtChanges != null) { string pwd = SQLHelper.ExecuteScalar("select pws from SysPara where name='rg'"); //string s KSPrj.FrmInputPws fip = new KSPrj.FrmInputPws("请输入(热工检修人员)密码"); fip.ShowDialog(); string strRet = fip.Text; string[] strRetA = strRet.Split(','); if (strRet.Length == 0) { return; } if (strRetA[1] == "ok") { if (pwd == strRetA[0]) { foreach (DataRow row in dtChanges.Rows) { sSql = "update tags set IsSet='" + row["IsSet"] + "', tag='" + row["tag"] + "', unit='" + row["unit"] + "', SetValue=" + PublicFunction.nullOrBadToSqlNULL(row["SetValue"]) + " where [id]=" + row["id"].ToString(); lstSql.Add(sSql); } try { SQLHelper.ExecuteSql(lstSql); m_viewTagValue.Table.AcceptChanges(); if (this.UnitNO == 5) { FTableTags.setFill(); } else { STableTags.setFill(); } MessageBox.Show("保存成功!"); this.Close(); } catch { m_viewTagValue.Table.RejectChanges(); MessageBox.Show("保存失败!"); } } else { MessageBox.Show("密码错误!"); fip.Dispose(); } } } else { MessageBox.Show("数据未改变!"); this.Close(); } }