基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
using DevExpress.Utils;
|
||||
using DevExpress.XtraEditors.Repository;
|
||||
using DevExpress.XtraGrid.Columns;
|
||||
using DevExpress.XtraGrid.Views.Base;
|
||||
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
||||
using Lskj.Control;
|
||||
using Lskj.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.GarbledCodeProcessing
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// ini文件内段落名
|
||||
/// </summary>
|
||||
public string company = "乱码处理";
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void btnBegin_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ConnectServer())
|
||||
{
|
||||
DataTable DT = SqlHelper.ExecuteDataTable(@"
|
||||
select hr_emp_rizhinr,hr_emp_billdocument_id from HR_ygrizhidjtab where hr_emp_rizhinr like '%{%';");
|
||||
|
||||
|
||||
|
||||
GridColumn gridColumn1 = new GridColumn();
|
||||
gridColumn1.FieldName = "hr_emp_billdocument_id";
|
||||
gridColumn1.Name = "hr_emp_billdocument_id";
|
||||
gridColumn1.Caption = "主键";
|
||||
gridColumn1.Width = 200;
|
||||
gridColumn1.VisibleIndex = 0;
|
||||
|
||||
this.gridView.Columns.Add(gridColumn1);
|
||||
|
||||
|
||||
|
||||
GridColumn gridColumn = new GridColumn();
|
||||
gridColumn.FieldName = "hr_emp_rizhinr";
|
||||
gridColumn.Name = "hr_emp_rizhinr";
|
||||
gridColumn.Caption = "日志内容";
|
||||
gridColumn.Width = 200;
|
||||
gridColumn.VisibleIndex = 1;
|
||||
|
||||
|
||||
gridColumn.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList;
|
||||
gridColumn.OptionsColumn.AllowEdit = false;
|
||||
gridColumn.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
|
||||
|
||||
gridColumn.OptionsColumn.AllowMerge = DefaultBoolean.False;
|
||||
|
||||
gridColumn.AppearanceCell.Options.UseFont = true;
|
||||
|
||||
this.gridView.Columns.Add(gridColumn);
|
||||
|
||||
RepositoryItemRichTextEdit richEdit = new RepositoryItemRichTextEdit();
|
||||
richEdit.Encoding = Encoding.UTF8;//乱码问题
|
||||
gridControl.RepositoryItems.Add(richEdit);
|
||||
gridColumn.ColumnEdit = richEdit;
|
||||
|
||||
|
||||
|
||||
|
||||
gridControl.DataSource = DT;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string ff(string value) {
|
||||
|
||||
RichTextBox rtfObj = new RichTextBox();
|
||||
rtfObj.Rtf = value;
|
||||
string disValue = rtfObj.Text;
|
||||
return disValue;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataTable dt = gridControl.DataSource as DataTable;
|
||||
string sql = " update HR_ygrizhidjtab set hr_emp_rizhinr='{0}' where hr_emp_billdocument_id='{1}'";
|
||||
string updateSql = string.Empty;
|
||||
string text = string.Empty;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
updateSql = string.Empty;
|
||||
text = string.Empty;
|
||||
|
||||
text = ff(dr["hr_emp_rizhinr"] + "");
|
||||
|
||||
updateSql = string.Format(sql, text.Replace("'", "''"), dr["hr_emp_billdocument_id"] + "");
|
||||
SqlHelper.ExecuteNonQuery(updateSql);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MessageUtil.Show("成功");
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region 连接服务器
|
||||
/// <summary>
|
||||
/// <para>说明:连接服务器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-09 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="isSave">if set to <c>true</c> [is save].</param>
|
||||
public bool ConnectServer(bool isSave = false)
|
||||
{
|
||||
string serverName = this.txtSeverId.Text.Trim();//地址
|
||||
string dbName = this.txtDataBase.Text.Trim();//数据库名
|
||||
string user = this.txtName.Text.Trim();//用户名
|
||||
string password = this.txtPassword.Text.Trim();//密码
|
||||
|
||||
if (string.IsNullOrWhiteSpace(serverName))
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ServerNameIsNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dbName))
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ServerDBIsNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(user))
|
||||
{
|
||||
MessageUtil.Show("请重新输入用户名");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 测试数据库连接
|
||||
try
|
||||
{
|
||||
if (ConnectingToDatabase())
|
||||
{
|
||||
if (isSave)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IniUtil.IniWriteValue(company, "serverName", serverName);
|
||||
IniUtil.IniWriteValue(company, "dbName", dbName);
|
||||
IniUtil.IniWriteValue(company, "user", user);
|
||||
IniUtil.IniWriteValue(company, "password", password);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ConnectFault);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ConnectFault);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:创建数据库连接</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public bool ConnectingToDatabase()
|
||||
{
|
||||
string connStr = GetConnection();
|
||||
if (SqlHelper._connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlHelper._connection.Close();
|
||||
SqlHelper._connection.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
SqlHelper._connection = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
SqlHelper._connection = new SqlConnection(connStr);
|
||||
SqlHelper._connection.Open();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogHelper.Instance.WriteLog(ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取连接服务器的字符串
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetConnection()
|
||||
{
|
||||
return string.Format("Server={0};Database={1};Persist Security Info=True;User ID={2};Password={3};Connection Timeout=5;MultipleActiveResultSets=true", txtSeverId.Text.ToString(), txtDataBase.Text.ToString(), txtName.Text.ToString(), txtPassword.Text.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user