打开word 保存
private void SelectGwSms_Load(object sender, EventArgs e)
{
try
{
DataTable dat_gwsms = dataService.DBAccess.Query("SQL_selectksgwsmsForm_select", new string[] { str_deppostid });
if (dat_gwsms.Rows.Count > 0)
{
if (dat_gwsms.Rows[0]["fsms"].ToString() == "查看说明书")
{
string str_wjm = str_gwmc + DateTime.Now.ToLongDateString();
byte[] bytes = (byte[])dat_gwsms.Rows[0]["ffsms"]; //以字符流的形式下载文件
FileStream fs = new FileStream("c:/" + str_wjm + ".docx", FileMode.Create);//.doc,.docx
StreamWriter SWriter = new StreamWriter(fs, Encoding.Default);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
richEditControl1.LoadDocument("c:/" + str_wjm + ".docx", DocumentFormat.OpenXml);
richEditControl1.ReadOnly = true;
File.Delete("c:/" + str_wjm + ".docx");
Document doc = richEditControl1.Document;
doc.BeginUpdate();
CharacterProperties cp = doc.BeginUpdateCharacters(0, doc.Text.Length);
cp.FontName = "宋体";
doc.EndUpdateCharacters(cp);
doc.EndUpdate();
richEditControl1.ReadOnly = true;
labelControl1.Text = "当前岗位为:" + str_gwmc + "" + str_jb + "";
}
else
{
richEditControl1.Text = "";
richEditControl1.ReadOnly = true;
}
}
}
catch (Exception ex)
{
Framework.Core.MessageService.ShowError(ex, "Human.HumanDepartmentPost");
}
}
private void SelectGwSms_Load(object sender, EventArgs e)
{
try
{
DataTable dat_gwsms = dataService.DBAccess.Query("SQL_selectksgwsmsForm_select", new string[] { str_deppostid });
if (dat_gwsms.Rows.Count > 0)
{
if (dat_gwsms.Rows[0]["fsms"].ToString() == "查看说明书")
{
string str_wjm = str_gwmc + DateTime.Now.ToLongDateString();
byte[] bytes = (byte[])dat_gwsms.Rows[0]["ffsms"]; //以字符流的形式下载文件
FileStream fs = new FileStream("c:/" + str_wjm + ".docx", FileMode.Create);//.doc,.docx
StreamWriter SWriter = new StreamWriter(fs, Encoding.Default);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
richEditControl1.LoadDocument("c:/" + str_wjm + ".docx", DocumentFormat.OpenXml);
richEditControl1.ReadOnly = true;
File.Delete("c:/" + str_wjm + ".docx");
Document doc = richEditControl1.Document;
doc.BeginUpdate();
CharacterProperties cp = doc.BeginUpdateCharacters(0, doc.Text.Length);
cp.FontName = "宋体";
doc.EndUpdateCharacters(cp);
doc.EndUpdate();
richEditControl1.ReadOnly = true;
labelControl1.Text = "当前岗位为:" + str_gwmc + "" + str_jb + "";
}
else
{
richEditControl1.Text = "";
richEditControl1.ReadOnly = true;
}
}
}
catch (Exception ex)
{
Framework.Core.MessageService.ShowError(ex, "Human.HumanDepartmentPost");
}
}