123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- 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;
- /// <summary>
- /// 加载的类型
- /// </summary>
- 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 );
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 新建
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnNewCreate_Click( object sender, EventArgs e )
- {
- this.textBoxEx1.Text = "";
- this.comboBoxTreeViewEx1.Text = "";
- this.textBoxEx2.Text = "";
- this.checkBoxEx1.Checked = false;
- this.buttonEx1.Text = " 添 加";
- }
- /// <summary>
- /// 添加按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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( "修改失败!" );
- }
- }
- }
- /// <summary>
- /// 删除按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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( "删除失败!" );
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 下拉框发生改变时
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void comboBoxTreeViewEx1_TextChanged( object sender, EventArgs e )
- {
- this.labelEx2.Text = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ReminderSettings( this.comboBoxTreeViewEx1.Text.Trim() );
- }
- /// <summary>
- /// 设置提醒天数只能输入数字
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void textBoxEx2_KeyPress( object sender, KeyPressEventArgs e )
- {
- if ( e.KeyChar != 8 && !Char.IsDigit( e.KeyChar ) )
- {
- e.Handled = true;
- }
- }
- /// <summary>
- /// 双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 = " 修 改";
- }
- }
- }
- /// <summary>
- /// 定义显示
- /// </summary>
- 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 );
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click( object sender, EventArgs e )
- {
- this.Close();
- }
- enum Condition
- {
- 宝宝出生 = 0,
- 预产期 = 1,
- 客户生日 = 2,
- 婚庆日期 = 3,
- 结婚纪念日 = 4
- }
- enum Status
- {
- 启动 = 0,
- 未启动 = 1
- }
- public enum RemindSetLoadType
- {
- 医院跟踪今日提醒,
- 客户管理今日提醒
- }
- }
- }
|