using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
namespace LYFZ.Software.MainBusiness.HospitalTrackingSystem
{
public partial class RemindSet : LYFZ.Software.UI.HospitalTrackingSystem.RemindSet
{
string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
LYFZ.BLL.BLL_ErpHospitalRemindSettings ambll = new BLL.BLL_ErpHospitalRemindSettings();
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public bool ok = false;
///
/// 加载的类型
///
public RemindSetLoadType StrRemindSetLoadType;
public RemindSet()
{
this.btnClose.Click += btnClose_Click;
this.buttonEx1.Click += buttonEx1_Click;
this.Load += RemindSet_Load;
this.dgvRemind.CellDoubleClick += dgvRemind_CellDoubleClick;
this.textBoxEx2.KeyPress += textBoxEx2_KeyPress;
this.btnDelete.Click += btnDelete_Click;
this.comboBoxTreeViewEx1.TextChanged += comboBoxTreeViewEx1_TextChanged;
this.buttonEx1.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.RemindedSet );
this.btnNewCreate.Click += btnNewCreate_Click;
this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.Delete );
}
///
/// 窗体加载事件
///
///
///
void RemindSet_Load( object sender, EventArgs e )
{
this.comboBoxTreeViewEx1.Items.Clear();
if ( this.StrRemindSetLoadType == RemindSetLoadType.客户管理今日提醒 )
{
this.comboBoxTreeViewEx1.Items.Add( new ListItem( "宝宝出生", "0" ) );
this.comboBoxTreeViewEx1.Items.Add( new ListItem( "客户生日", "2" ) );
this.comboBoxTreeViewEx1.Items.Add( new ListItem( "婚庆日期", "3" ) );
this.comboBoxTreeViewEx1.Items.Add( new ListItem( "结婚纪念日", "4" ) );
}
else if ( this.StrRemindSetLoadType == RemindSetLoadType.医院跟踪今日提醒 )
{
this.comboBoxTreeViewEx1.Items.Add( new ListItem( "宝宝出生", "0" ) );
this.comboBoxTreeViewEx1.Items.Add( new ListItem( "预产期", "1" ) );
}
this.GetLot();
}
///
/// 新建
///
///
///
void btnNewCreate_Click( object sender, EventArgs e )
{
this.textBoxEx1.Text = "";
this.comboBoxTreeViewEx1.Text = "";
this.textBoxEx2.Text = "";
this.checkBoxEx1.Checked = false;
this.buttonEx1.Text = " 添 加";
}
///
/// 添加按钮
///
///
///
void buttonEx1_Click( object sender, EventArgs e )
{
if ( this.buttonEx1.Text == " 添 加" )
{
if ( this.textBoxEx1.Text == "" )
{
MessageBoxCustom.Show( "请设置提醒名称!" );
return;
}
if ( this.comboBoxTreeViewEx1.Text == "" )
{
MessageBoxCustom.Show( "请选择提醒条件!" );
return;
}
if ( this.textBoxEx2.Text == "" )
{
MessageBoxCustom.Show( "请输入天数!" );
return;
}
DateTime strTime = SDateTime.Now;
LYFZ.Model.Model_ErpHospitalRemindSettings model = new Model.Model_ErpHospitalRemindSettings();
model.Hrs_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
model.Hrs_RemindName = this.textBoxEx1.Text.Trim().ToString();
model.Hrs_RemindConditions = Convert.ToInt32( ((ListItem)this.comboBoxTreeViewEx1.SelectedItem).Value );
model.Hrs_RemindDays = Convert.ToInt32( this.textBoxEx2.Text.Trim() );
if ( this.checkBoxEx1.Checked == true )
{
model.Hrs_StartState = 0;
}
else
{
model.Hrs_StartState = 1;
}
model.Hrs_CreateDatetime = SDateTime.Now;
model.Hrs_CreateName = strUserID;
if ( ambll.Add( model ) )
{
MessageBoxCustom.Show( "添加成功!" );
this.textBoxEx1.Text = "";
this.comboBoxTreeViewEx1.Text = "";
this.textBoxEx2.Text = "";
ok = true;
this.GetLot();
}
else
{
MessageBoxCustom.Show( "添加失败!" );
}
}
else if ( this.buttonEx1.Text == " 修 改" )
{
if ( this.textBoxEx1.Text == "" )
{
MessageBoxCustom.Show( "请设置提醒名称!" );
return;
}
if ( this.comboBoxTreeViewEx1.Text == "" )
{
MessageBoxCustom.Show( "请选择提醒条件!" );
return;
}
if ( this.textBoxEx2.Text == "" )
{
MessageBoxCustom.Show( "请输入天数!" );
return;
}
DateTime strTime = SDateTime.Now;
LYFZ.Model.Model_ErpHospitalRemindSettings model = ambll.GetModel( Convert.ToInt32( dgvRemind.CurrentRow.Cells["ID"].Value ) );
model.Hrs_RemindName = this.textBoxEx1.Text.Trim().ToString();
model.Hrs_RemindConditions = Convert.ToInt32( ((ListItem)this.comboBoxTreeViewEx1.SelectedItem).Value );
model.Hrs_RemindDays = Convert.ToInt32( this.textBoxEx2.Text.Trim() );
if ( this.checkBoxEx1.Checked == true )
{
model.Hrs_StartState = 0;
}
else
{
model.Hrs_StartState = 1;
}
model.Hrs_UpdateDatetime = SDateTime.Now;
model.Hrs_UpdateName = strUserID;
if ( ambll.Update( model ) )
{
MessageBoxCustom.Show( "修改成功!" );
this.Text = "";
ok = true;
this.GetLot();
}
else
{
MessageBoxCustom.Show( "修改失败!" );
}
}
}
///
/// 删除按钮
///
///
///
void btnDelete_Click( object sender, EventArgs e )
{
if ( this.dgvRemind.SelectedRows != null && this.dgvRemind.SelectedRows.Count > 0 )
{
if ( this.dgvRemind.CurrentRow != null )
{
if ( this.dgvRemind.SelectedRows.Count > 0 )
{
if ( MessageBoxCustom.Show( "你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo ) == DialogResult.Yes )
{
if ( ambll.Delete( ambll.GetModel( Convert.ToInt32( dgvRemind.CurrentRow.Cells["ID"].Value ) ) ) )
{
MessageBoxCustom.Show( "删除成功!" );
ok = true;
this.GetLot();
}
else
{
MessageBoxCustom.Show( "删除失败!" );
}
}
}
}
}
}
///
/// 下拉框发生改变时
///
///
///
void comboBoxTreeViewEx1_TextChanged( object sender, EventArgs e )
{
this.labelEx2.Text = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ReminderSettings( this.comboBoxTreeViewEx1.Text.Trim() );
}
///
/// 设置提醒天数只能输入数字
///
///
///
void textBoxEx2_KeyPress( object sender, KeyPressEventArgs e )
{
if ( e.KeyChar != 8 && !Char.IsDigit( e.KeyChar ) )
{
e.Handled = true;
}
}
///
/// 双击事件
///
///
///
void dgvRemind_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
{
if ( e.ColumnIndex >= 0 && e.RowIndex >= 0 )
{
if ( this.dgvRemind.CurrentRow != null )
{
this.labelEx2.Text = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ReminderSettings( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim() );
this.textBoxEx1.Text = this.dgvRemind.CurrentRow.Cells["提醒名称"].Value.ToString();
//this.comboBoxTreeViewEx1.Text = this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Substring(0, 4);
if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "宝宝出生" ) != -1 )
{
this.comboBoxTreeViewEx1.Text = "宝宝出生";
}
else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "预产期" ) != -1 )
{
this.comboBoxTreeViewEx1.Text = "预产期";
}
else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "客户生日" ) != -1 )
{
this.comboBoxTreeViewEx1.Text = "客户生日";
}
else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "婚庆日期" ) != -1 )
{
this.comboBoxTreeViewEx1.Text = "婚庆日期";
}
else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "结婚纪念日" ) != -1 )
{
this.comboBoxTreeViewEx1.Text = "结婚纪念日";
}
this.textBoxEx2.Text = this.dgvRemind.CurrentRow.Cells["提醒天数"].Value.ToString();
string Strdf = this.dgvRemind.CurrentRow.Cells["启动状态"].Value.ToString();
if ( this.dgvRemind.CurrentRow.Cells["启动状态"].Value.ToString().Trim() == "启动" )
{
this.checkBoxEx1.Checked = true;
}
else
{
this.checkBoxEx1.Checked = false;
}
this.buttonEx1.Text = " 修 改";
}
}
}
///
/// 定义显示
///
void GetLot()
{
string StrWhere = "";
for ( int i = 0; i < this.comboBoxTreeViewEx1.Items.Count; i++ )
{
ListItem itemList = (ListItem)this.comboBoxTreeViewEx1.Items[i];
StrWhere += "'" + itemList.Value + "',";
}
StrWhere = "Hrs_RemindConditions in (" + StrWhere.TrimEnd( ',' ) + ")";
DataTable tbl = orbll.GetView_Custom( "tb_ErpHospitalRemindSettings", StrWhere: StrWhere, ShowColumnName: "ID,Hrs_RemindName as 提醒名称,Hrs_RemindConditions as 提醒条件, Hrs_RemindDays as 提醒天数 ,Hrs_StartState as 启动状态" ).Tables[0];
this.dgvRemind.Columns.Clear();
this.dgvRemind.Rows.Clear();
for ( int i = 0; i < tbl.Columns.Count; i++ )
{
DataGridViewColumn column = null;
column = new DataGridViewColumn();
column.ReadOnly = true;
column.Name = tbl.Columns[i].ColumnName.Trim();
column.HeaderText = tbl.Columns[i].ColumnName.Trim();
if ( column.Name == "ID" )
{
column.Visible = false;
}
if ( column.Name == "提醒天数" )
{
column.Visible = false;
}
this.dgvRemind.Columns.Add( column );
}
for ( int i = 0; i < tbl.Rows.Count; i++ )
{
DataGridViewRow row = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["ID"].ToString();
row.Cells.Add( cell );
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["提醒名称"].ToString();
row.Cells.Add( cell );
cell = new DataGridViewTextBoxCell();
cell.Value = ((Condition)Convert.ToInt32( tbl.Rows[i]["提醒条件"].ToString() )).ToString() + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ReminderSettings( Convert.ToInt32( tbl.Rows[i]["提醒条件"] ) ) + tbl.Rows[i]["提醒天数"].ToString() + "天";
row.Cells.Add( cell );
//if (tbl.Rows[i]["提醒条件"].ToString().Trim() == "2" || tbl.Rows[i]["提醒条件"].ToString().Trim() == "3")
//{
// cell = new DataGridViewTextBoxCell();
// cell.Value = ((Condition)Convert.ToInt32(tbl.Rows[i]["提醒条件"].ToString())).ToString() + "前" + tbl.Rows[i]["提醒天数"].ToString() + "天";
// row.Cells.Add(cell);
//}
//else
//{
// cell = new DataGridViewTextBoxCell();
// cell.Value = ((Condition)Convert.ToInt32(tbl.Rows[i]["提醒条件"].ToString())).ToString() + "满" + tbl.Rows[i]["提醒天数"].ToString() + "天";
// row.Cells.Add(cell);
//}
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["提醒天数"].ToString();
row.Cells.Add( cell );
cell = new DataGridViewTextBoxCell();
cell.Value = ((Status)Convert.ToInt32( tbl.Rows[i]["启动状态"] )).ToString();
row.Cells.Add( cell );
this.dgvRemind.Rows.Add( row );
}
}
///
/// 关闭窗体
///
///
///
void btnClose_Click( object sender, EventArgs e )
{
this.Close();
}
enum Condition
{
宝宝出生 = 0,
预产期 = 1,
客户生日 = 2,
婚庆日期 = 3,
结婚纪念日 = 4
}
enum Status
{
启动 = 0,
未启动 = 1
}
public enum RemindSetLoadType
{
医院跟踪今日提醒,
客户管理今日提醒
}
}
}