RemindSet.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;
  10. using System.Web.UI.WebControls;
  11. namespace LYFZ.Software.MainBusiness.HospitalTrackingSystem
  12. {
  13. public partial class RemindSet : LYFZ.Software.UI.HospitalTrackingSystem.RemindSet
  14. {
  15. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  16. LYFZ.BLL.BLL_ErpHospitalRemindSettings ambll = new BLL.BLL_ErpHospitalRemindSettings();
  17. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  18. public bool ok = false;
  19. /// <summary>
  20. /// 加载的类型
  21. /// </summary>
  22. public RemindSetLoadType StrRemindSetLoadType;
  23. public RemindSet()
  24. {
  25. this.btnClose.Click += btnClose_Click;
  26. this.buttonEx1.Click += buttonEx1_Click;
  27. this.Load += RemindSet_Load;
  28. this.dgvRemind.CellDoubleClick += dgvRemind_CellDoubleClick;
  29. this.textBoxEx2.KeyPress += textBoxEx2_KeyPress;
  30. this.btnDelete.Click += btnDelete_Click;
  31. this.comboBoxTreeViewEx1.TextChanged += comboBoxTreeViewEx1_TextChanged;
  32. this.buttonEx1.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.RemindedSet );
  33. this.btnNewCreate.Click += btnNewCreate_Click;
  34. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.Delete );
  35. }
  36. /// <summary>
  37. /// 窗体加载事件
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="e"></param>
  41. void RemindSet_Load( object sender, EventArgs e )
  42. {
  43. this.comboBoxTreeViewEx1.Items.Clear();
  44. if ( this.StrRemindSetLoadType == RemindSetLoadType.客户管理今日提醒 )
  45. {
  46. this.comboBoxTreeViewEx1.Items.Add( new ListItem( "宝宝出生", "0" ) );
  47. this.comboBoxTreeViewEx1.Items.Add( new ListItem( "客户生日", "2" ) );
  48. this.comboBoxTreeViewEx1.Items.Add( new ListItem( "婚庆日期", "3" ) );
  49. this.comboBoxTreeViewEx1.Items.Add( new ListItem( "结婚纪念日", "4" ) );
  50. }
  51. else if ( this.StrRemindSetLoadType == RemindSetLoadType.医院跟踪今日提醒 )
  52. {
  53. this.comboBoxTreeViewEx1.Items.Add( new ListItem( "宝宝出生", "0" ) );
  54. this.comboBoxTreeViewEx1.Items.Add( new ListItem( "预产期", "1" ) );
  55. }
  56. this.GetLot();
  57. }
  58. /// <summary>
  59. /// 新建
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. void btnNewCreate_Click( object sender, EventArgs e )
  64. {
  65. this.textBoxEx1.Text = "";
  66. this.comboBoxTreeViewEx1.Text = "";
  67. this.textBoxEx2.Text = "";
  68. this.checkBoxEx1.Checked = false;
  69. this.buttonEx1.Text = " 添 加";
  70. }
  71. /// <summary>
  72. /// 添加按钮
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. void buttonEx1_Click( object sender, EventArgs e )
  77. {
  78. if ( this.buttonEx1.Text == " 添 加" )
  79. {
  80. if ( this.textBoxEx1.Text == "" )
  81. {
  82. MessageBoxCustom.Show( "请设置提醒名称!" );
  83. return;
  84. }
  85. if ( this.comboBoxTreeViewEx1.Text == "" )
  86. {
  87. MessageBoxCustom.Show( "请选择提醒条件!" );
  88. return;
  89. }
  90. if ( this.textBoxEx2.Text == "" )
  91. {
  92. MessageBoxCustom.Show( "请输入天数!" );
  93. return;
  94. }
  95. DateTime strTime = SDateTime.Now;
  96. LYFZ.Model.Model_ErpHospitalRemindSettings model = new Model.Model_ErpHospitalRemindSettings();
  97. model.Hrs_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  98. model.Hrs_RemindName = this.textBoxEx1.Text.Trim().ToString();
  99. model.Hrs_RemindConditions = Convert.ToInt32( ((ListItem)this.comboBoxTreeViewEx1.SelectedItem).Value );
  100. model.Hrs_RemindDays = Convert.ToInt32( this.textBoxEx2.Text.Trim() );
  101. if ( this.checkBoxEx1.Checked == true )
  102. {
  103. model.Hrs_StartState = 0;
  104. }
  105. else
  106. {
  107. model.Hrs_StartState = 1;
  108. }
  109. model.Hrs_CreateDatetime = SDateTime.Now;
  110. model.Hrs_CreateName = strUserID;
  111. if ( ambll.Add( model ) )
  112. {
  113. MessageBoxCustom.Show( "添加成功!" );
  114. this.textBoxEx1.Text = "";
  115. this.comboBoxTreeViewEx1.Text = "";
  116. this.textBoxEx2.Text = "";
  117. ok = true;
  118. this.GetLot();
  119. }
  120. else
  121. {
  122. MessageBoxCustom.Show( "添加失败!" );
  123. }
  124. }
  125. else if ( this.buttonEx1.Text == " 修 改" )
  126. {
  127. if ( this.textBoxEx1.Text == "" )
  128. {
  129. MessageBoxCustom.Show( "请设置提醒名称!" );
  130. return;
  131. }
  132. if ( this.comboBoxTreeViewEx1.Text == "" )
  133. {
  134. MessageBoxCustom.Show( "请选择提醒条件!" );
  135. return;
  136. }
  137. if ( this.textBoxEx2.Text == "" )
  138. {
  139. MessageBoxCustom.Show( "请输入天数!" );
  140. return;
  141. }
  142. DateTime strTime = SDateTime.Now;
  143. LYFZ.Model.Model_ErpHospitalRemindSettings model = ambll.GetModel( Convert.ToInt32( dgvRemind.CurrentRow.Cells["ID"].Value ) );
  144. model.Hrs_RemindName = this.textBoxEx1.Text.Trim().ToString();
  145. model.Hrs_RemindConditions = Convert.ToInt32( ((ListItem)this.comboBoxTreeViewEx1.SelectedItem).Value );
  146. model.Hrs_RemindDays = Convert.ToInt32( this.textBoxEx2.Text.Trim() );
  147. if ( this.checkBoxEx1.Checked == true )
  148. {
  149. model.Hrs_StartState = 0;
  150. }
  151. else
  152. {
  153. model.Hrs_StartState = 1;
  154. }
  155. model.Hrs_UpdateDatetime = SDateTime.Now;
  156. model.Hrs_UpdateName = strUserID;
  157. if ( ambll.Update( model ) )
  158. {
  159. MessageBoxCustom.Show( "修改成功!" );
  160. this.Text = "";
  161. ok = true;
  162. this.GetLot();
  163. }
  164. else
  165. {
  166. MessageBoxCustom.Show( "修改失败!" );
  167. }
  168. }
  169. }
  170. /// <summary>
  171. /// 删除按钮
  172. /// </summary>
  173. /// <param name="sender"></param>
  174. /// <param name="e"></param>
  175. void btnDelete_Click( object sender, EventArgs e )
  176. {
  177. if ( this.dgvRemind.SelectedRows != null && this.dgvRemind.SelectedRows.Count > 0 )
  178. {
  179. if ( this.dgvRemind.CurrentRow != null )
  180. {
  181. if ( this.dgvRemind.SelectedRows.Count > 0 )
  182. {
  183. if ( MessageBoxCustom.Show( "你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo ) == DialogResult.Yes )
  184. {
  185. if ( ambll.Delete( ambll.GetModel( Convert.ToInt32( dgvRemind.CurrentRow.Cells["ID"].Value ) ) ) )
  186. {
  187. MessageBoxCustom.Show( "删除成功!" );
  188. ok = true;
  189. this.GetLot();
  190. }
  191. else
  192. {
  193. MessageBoxCustom.Show( "删除失败!" );
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. /// <summary>
  201. /// 下拉框发生改变时
  202. /// </summary>
  203. /// <param name="sender"></param>
  204. /// <param name="e"></param>
  205. void comboBoxTreeViewEx1_TextChanged( object sender, EventArgs e )
  206. {
  207. this.labelEx2.Text = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ReminderSettings( this.comboBoxTreeViewEx1.Text.Trim() );
  208. }
  209. /// <summary>
  210. /// 设置提醒天数只能输入数字
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. void textBoxEx2_KeyPress( object sender, KeyPressEventArgs e )
  215. {
  216. if ( e.KeyChar != 8 && !Char.IsDigit( e.KeyChar ) )
  217. {
  218. e.Handled = true;
  219. }
  220. }
  221. /// <summary>
  222. /// 双击事件
  223. /// </summary>
  224. /// <param name="sender"></param>
  225. /// <param name="e"></param>
  226. void dgvRemind_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
  227. {
  228. if ( e.ColumnIndex >= 0 && e.RowIndex >= 0 )
  229. {
  230. if ( this.dgvRemind.CurrentRow != null )
  231. {
  232. this.labelEx2.Text = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ReminderSettings( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim() );
  233. this.textBoxEx1.Text = this.dgvRemind.CurrentRow.Cells["提醒名称"].Value.ToString();
  234. //this.comboBoxTreeViewEx1.Text = this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Substring(0, 4);
  235. if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "宝宝出生" ) != -1 )
  236. {
  237. this.comboBoxTreeViewEx1.Text = "宝宝出生";
  238. }
  239. else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "预产期" ) != -1 )
  240. {
  241. this.comboBoxTreeViewEx1.Text = "预产期";
  242. }
  243. else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "客户生日" ) != -1 )
  244. {
  245. this.comboBoxTreeViewEx1.Text = "客户生日";
  246. }
  247. else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "婚庆日期" ) != -1 )
  248. {
  249. this.comboBoxTreeViewEx1.Text = "婚庆日期";
  250. }
  251. else if ( this.dgvRemind.CurrentRow.Cells["提醒条件"].Value.ToString().Trim().IndexOf( "结婚纪念日" ) != -1 )
  252. {
  253. this.comboBoxTreeViewEx1.Text = "结婚纪念日";
  254. }
  255. this.textBoxEx2.Text = this.dgvRemind.CurrentRow.Cells["提醒天数"].Value.ToString();
  256. string Strdf = this.dgvRemind.CurrentRow.Cells["启动状态"].Value.ToString();
  257. if ( this.dgvRemind.CurrentRow.Cells["启动状态"].Value.ToString().Trim() == "启动" )
  258. {
  259. this.checkBoxEx1.Checked = true;
  260. }
  261. else
  262. {
  263. this.checkBoxEx1.Checked = false;
  264. }
  265. this.buttonEx1.Text = " 修 改";
  266. }
  267. }
  268. }
  269. /// <summary>
  270. /// 定义显示
  271. /// </summary>
  272. void GetLot()
  273. {
  274. string StrWhere = "";
  275. for ( int i = 0; i < this.comboBoxTreeViewEx1.Items.Count; i++ )
  276. {
  277. ListItem itemList = (ListItem)this.comboBoxTreeViewEx1.Items[i];
  278. StrWhere += "'" + itemList.Value + "',";
  279. }
  280. StrWhere = "Hrs_RemindConditions in (" + StrWhere.TrimEnd( ',' ) + ")";
  281. 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];
  282. this.dgvRemind.Columns.Clear();
  283. this.dgvRemind.Rows.Clear();
  284. for ( int i = 0; i < tbl.Columns.Count; i++ )
  285. {
  286. DataGridViewColumn column = null;
  287. column = new DataGridViewColumn();
  288. column.ReadOnly = true;
  289. column.Name = tbl.Columns[i].ColumnName.Trim();
  290. column.HeaderText = tbl.Columns[i].ColumnName.Trim();
  291. if ( column.Name == "ID" )
  292. {
  293. column.Visible = false;
  294. }
  295. if ( column.Name == "提醒天数" )
  296. {
  297. column.Visible = false;
  298. }
  299. this.dgvRemind.Columns.Add( column );
  300. }
  301. for ( int i = 0; i < tbl.Rows.Count; i++ )
  302. {
  303. DataGridViewRow row = new DataGridViewRow();
  304. DataGridViewCell cell = null;
  305. cell = new DataGridViewTextBoxCell();
  306. cell.Value = tbl.Rows[i]["ID"].ToString();
  307. row.Cells.Add( cell );
  308. cell = new DataGridViewTextBoxCell();
  309. cell.Value = tbl.Rows[i]["提醒名称"].ToString();
  310. row.Cells.Add( cell );
  311. cell = new DataGridViewTextBoxCell();
  312. 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() + "天";
  313. row.Cells.Add( cell );
  314. //if (tbl.Rows[i]["提醒条件"].ToString().Trim() == "2" || tbl.Rows[i]["提醒条件"].ToString().Trim() == "3")
  315. //{
  316. // cell = new DataGridViewTextBoxCell();
  317. // cell.Value = ((Condition)Convert.ToInt32(tbl.Rows[i]["提醒条件"].ToString())).ToString() + "前" + tbl.Rows[i]["提醒天数"].ToString() + "天";
  318. // row.Cells.Add(cell);
  319. //}
  320. //else
  321. //{
  322. // cell = new DataGridViewTextBoxCell();
  323. // cell.Value = ((Condition)Convert.ToInt32(tbl.Rows[i]["提醒条件"].ToString())).ToString() + "满" + tbl.Rows[i]["提醒天数"].ToString() + "天";
  324. // row.Cells.Add(cell);
  325. //}
  326. cell = new DataGridViewTextBoxCell();
  327. cell.Value = tbl.Rows[i]["提醒天数"].ToString();
  328. row.Cells.Add( cell );
  329. cell = new DataGridViewTextBoxCell();
  330. cell.Value = ((Status)Convert.ToInt32( tbl.Rows[i]["启动状态"] )).ToString();
  331. row.Cells.Add( cell );
  332. this.dgvRemind.Rows.Add( row );
  333. }
  334. }
  335. /// <summary>
  336. /// 关闭窗体
  337. /// </summary>
  338. /// <param name="sender"></param>
  339. /// <param name="e"></param>
  340. void btnClose_Click( object sender, EventArgs e )
  341. {
  342. this.Close();
  343. }
  344. enum Condition
  345. {
  346. 宝宝出生 = 0,
  347. 预产期 = 1,
  348. 客户生日 = 2,
  349. 婚庆日期 = 3,
  350. 结婚纪念日 = 4
  351. }
  352. enum Status
  353. {
  354. 启动 = 0,
  355. 未启动 = 1
  356. }
  357. public enum RemindSetLoadType
  358. {
  359. 医院跟踪今日提醒,
  360. 客户管理今日提醒
  361. }
  362. }
  363. }