2023-08-16 22:32:16 +08:00

239 lines
8.9 KiB
C#

using AIMSBLL;
using AIMSExtension;
using AIMSModel;
using DCSoftDotfuscate;
using DevComponents.DotNetBar.Controls;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace AIMS.OperationAanesthesia
{
public partial class frmNoticeLargeScreen : Form
{
//已选择的通知内容
public DataTable db;
//可选的通知内容
public DataTable tt;
public frmNoticeLargeScreen()
{
InitializeComponent();
this.MaximizeBox = false;
this.MinimizeBox = false;
}
private void frmNoticeLargeScreen_Load(object sender, EventArgs e)
{
DGVAss.AutoGenerateColumns = false;
DGVAdd.AutoGenerateColumns = false;
txtTime.SelectedIndex = 1;
FillDGVAss();
button1_Click(null, null);
FillDGVAdd();
}
/// <summary>
///填充到DGVADD
/// </summary>
public void FillDGVAdd()
{
DataTable tb = new DataTable();
tb = BNoticeTemplate.GetNoticeTemplate();
this.DGVAdd.DataSource = tb;
DGVAdd.ClearSelection();
}
/// <summary>
/// 填充到DGVASS
/// </summary>
public void FillDGVAss()
{
DGVAss.AutoGenerateColumns = false;
DataTable tb = new DataTable();
DateTime time = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
tb = BNoticeContent.GetNoticeContent(time);
this.DGVAss.DataSource = tb;
}
/// <summary>
/// 查询当天的手术患者信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
FullTreeView();
}
/// <summary>
/// 加载当天手术患者信息到treeView1
/// </summary>
private void FullTreeView()
{
try
{
}
catch (Exception exp)
{
PublicMethod.WriteLog(exp, ""); return;
}
}
/// <summary>
/// 赋值手术患者的信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
}
/// <summary>
/// 保存发送
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSave_Click(object sender, EventArgs e)
{
if (txtTime.Text == "填写显示时长")
{
MessageBox.Show("请填写显示时长!");
return;
}
if (txtTime.Text == "填写通知内容")
{
MessageBox.Show("请填写通知内容!");
return;
}
NoticeContent nc = new NoticeContent();
nc.Contents = lblName.Text + textBox2.Text;
nc.ReleaseTime = int.Parse(txtTime.Text);
nc.ReleaseCount = int.Parse(txtTime.Text) / 30;
nc.OperatorTime = DateTime.Now;
nc.OperatorId = PublicMethod.OperatorId;
BNoticeContent.Insert(nc);
MessageBox.Show("发送成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
FillDGVAss();
}
private void DGVAdd_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
DGVAdd.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
DGVAdd.RowHeadersDefaultCellStyle.Font,
rectangle,
DGVAdd.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = false;
fileDialog.Title = "请选择文件";
fileDialog.Filter = "(*.xls*,*.doc*,*.dot*,*.xlt*,*.xla*,*.ppt*,*.pps*,*.pot*,*.ppa*)|*.xls*;*.doc*;*.dot*;*.xlt*;*.xla*;*.ppt*;*.pps*;*.pot*;*.ppa*"; //设置要选择的文件的类型
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string file = fileDialog.FileName;//返回文件的完整路径
//MessageBox.Show(file);
FileInfo fileInfo = new FileInfo(file);
FTPTransmission.UploadFile(fileInfo, "office", "172.16.0.199", "", "");
NoticeContent nc = new NoticeContent();
nc.Contents = fileInfo.Name;
nc.OperatorTime = DateTime.Now;
nc.OperatorId = PublicMethod.OperatorId;
nc.ReleaseTime = int.Parse(txtTime.Text);
nc.ReleaseCount = 1;
nc.SendType = 1;
nc.SystemType = 0;
BNoticeContent.Insert(nc);
MessageBox.Show("发送成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
FillDGVAss();
}
}
private void DGVAdd_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
//判断类型
if (e.ColumnIndex == 1)
{
if (DGVAdd.Rows[e.RowIndex].Cells[2].Value.ToString() == "删除")
{
int id = Convert.ToInt32(DGVAdd.Rows[e.RowIndex].Cells[0].Value);
string value = DGVAdd.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : DGVAdd.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
BNoticeTemplate.Update("Contents='" + value + "' where Id=" + id, null);
}
else
{
string value = DGVAdd.Rows[e.RowIndex].Cells[1].Value == null ? "" : DGVAdd.Rows[e.RowIndex].Cells[1].Value.ToString();
if (value == "")
{
return;
}
NoticeTemplate NC = new NoticeTemplate();
NC.Contents = value;
NC.OperatorTime = DateTime.Now;
NC.OperatorId = PublicMethod.OperatorId;
DGVAdd.Rows[e.RowIndex].Cells[0].Value=BNoticeTemplate.Insert(NC);
DGVAdd.Rows[e.RowIndex].Cells[2].Value = "删除";
MessageBox.Show("添加成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void DGVAdd_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 2)
{
if (DGVAdd.Rows[e.RowIndex].Cells[2].Value.ToString() == "删除")
{
int id = Convert.ToInt32(DGVAdd.Rows[e.RowIndex].Cells[0].Value);
DialogResult dr = MessageBox.Show("确定要删除?", "系统提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
BNoticeTemplate.Delete("Id=" + id, null);
FillDGVAdd();
}
}
//else if (DGVAdd.Rows[e.RowIndex].Cells[2].Value.ToString() == "增加" || DGVAdd.Rows[e.RowIndex].Cells[2].Value.ToString() == "")
//{
// string value = DGVAdd.Rows[e.RowIndex].Cells[1].Value == null ? "" : DGVAdd.Rows[e.RowIndex].Cells[1].Value.ToString();
// if (value == "")
// {
// MessageBox.Show("请添加通知内容", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// return;
// }
// NoticeTemplate NC = new NoticeTemplate();
// NC.Contents = value;
// NC.OperatorTime = DateTime.Now;
// NC.OperatorId = PublicMethod.OperatorId;
// BNoticeTemplate.Insert(NC);
// MessageBox.Show("添加成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// FillDGVAdd();
//}
}
}
private void DGVAdd_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == 1)
{
string value = DGVAdd.Rows[e.RowIndex].Cells[1].Value == null ? "" : DGVAdd.Rows[e.RowIndex].Cells[1].Value.ToString();
textBox2.Text = value;
}
}
}
}