DispatchDoor.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. namespace LYFZ.Software.MainBusiness.HospitalTrackingSystem
  10. {
  11. public partial class DispatchDoor : LYFZ.Software.UI.HospitalTrackingSystem.DispatchDoor
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. LYFZ.BLL.BLL_ErpHospitalDispatchDoor ambll = new BLL.BLL_ErpHospitalDispatchDoor();
  15. public DispatchDoor()
  16. {
  17. this.Load += DispatchDoor_Load;
  18. this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
  19. this.btnDelete.Click += btnDelete_Click;
  20. this.btnAdding.Click += btnAdding_Click;
  21. this.btnUpdate.Click += btnUpdate_Click;
  22. this.btnOK.Click += btnOK_Click;
  23. this.btnAdding.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.AddSendSingleTask);
  24. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.DelSendSingleTask);
  25. this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.UpdateSendSingleTask);
  26. }
  27. Model.CameraTimeTemplate currentSelectCameraTime = null;
  28. /// <summary>
  29. /// 当前选择的档期
  30. /// </summary>
  31. public Model.CameraTimeTemplate CurrentSelectCameraTime { get => currentSelectCameraTime; set => currentSelectCameraTime = value; }
  32. /// <summary>
  33. /// 订单号
  34. /// </summary>
  35. public string StrOrderNumber;
  36. /// <summary>
  37. /// 是否保存
  38. /// </summary>
  39. public bool IsSaveed = false;
  40. /// <summary>
  41. /// 选择的ID
  42. /// </summary>
  43. public int SelectID = 0;
  44. /// <summary>
  45. /// 窗体加载
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. void DispatchDoor_Load(object sender, EventArgs e)
  50. {
  51. this.dgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  52. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtMyselfPhone);
  53. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtHusbandPhone);
  54. IntentionsEntered frm = new IntentionsEntered();
  55. this.txtNumber.Text = StrOrderNumber;
  56. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  57. DataTable dt = orbll.GetView_Custom("View_HospitalContact", StrWhere: "来单批号='" + StrOrderNumber + "'", ShowColumnName: "来单批号,客户姓名,本人手机,老公手机,客户区域,宝宝姓名,宝宝年龄,业务意向").Tables[0];
  58. this.txtName.Text = dt.Rows[0]["客户姓名"].ToString();
  59. this.txtMyselfPhone.Text = dt.Rows[0]["本人手机"].ToString();
  60. this.txtHusbandPhone.Text = dt.Rows[0]["老公手机"].ToString();
  61. this.txtAreas.Text = dt.Rows[0]["客户区域"].ToString();
  62. this.txtBabyName.Text = dt.Rows[0]["宝宝姓名"].ToString();
  63. this.txtBabyAge.Text = dt.Rows[0]["宝宝年龄"].ToString();
  64. this.txtBusinessType.Text = dt.Rows[0]["业务意向"].ToString();
  65. this.PublicFunctionRows();
  66. }
  67. /// <summary>
  68. /// 双击事件
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  73. {
  74. if (this.dgvData.SelectedRows != null && this.dgvData.SelectedRows.Count > 0)
  75. { this.btnUpdate_Click(this, e); }
  76. // this.btnOK_Click(this, null);
  77. }
  78. /// <summary>
  79. /// 删除按钮
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. void btnDelete_Click(object sender, EventArgs e)
  84. {
  85. if (this.dgvData.Rows.Count > 0 && this.dgvData.SelectedRows.Count > 0)
  86. {
  87. if (this.dgvData.CurrentRow != null)
  88. {
  89. if (this.dgvData.SelectedRows.Count > 0)
  90. {
  91. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  92. {
  93. if (ambll.Delete(Convert.ToInt32(dgvData.CurrentRow.Cells["ID"].Value)))
  94. {
  95. this.IsSaveed = true;
  96. MessageBoxCustom.Show("删除成功!");
  97. this.PublicFunctionRows();
  98. }
  99. else
  100. { MessageBoxCustom.Show("删除失败!"); }
  101. }
  102. }
  103. }
  104. }
  105. else
  106. { MessageBoxCustom.Show("请选择要删除的数据!"); }
  107. }
  108. /// <summary>
  109. /// 添加派单
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. void btnAdding_Click(object sender, EventArgs e)
  114. {
  115. if (this.txtNumber.Text != "")
  116. {
  117. AddingSendSingle frm = new AddingSendSingle();
  118. frm.StrOrderNumber = this.StrOrderNumber;
  119. frm.ShowDialog();
  120. if (frm.IsSaveed)
  121. {
  122. this.IsSaveed = true;
  123. this.PublicFunctionRows();
  124. }
  125. }
  126. else
  127. { MessageBoxCustom.Show("请选择客户进行添加!"); }
  128. }
  129. /// <summary>
  130. /// 修改派单
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. void btnUpdate_Click(object sender, EventArgs e)
  135. {
  136. AddingSendSingle frm = new AddingSendSingle();
  137. frm.TeskRow = this.dgvData.CurrentRow;
  138. frm.ShowDialog();
  139. if (frm.IsSaveed)
  140. {
  141. this.IsSaveed = true;
  142. this.PublicFunctionRows();
  143. }
  144. }
  145. /// <summary>
  146. /// 确定
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. void btnOK_Click(object sender, EventArgs e)
  151. {
  152. if (this.dgvData.SelectedRows.Count > 0)
  153. {
  154. this.IsSaveed = true;
  155. this.SelectID = Convert.ToInt32(this.dgvData.SelectedRows[0].Cells["ID"].Value);
  156. this.Close();
  157. }
  158. else
  159. { MessageBoxCustom.Show("请选择派单数据!"); }
  160. }
  161. /// <summary>
  162. /// 创建行
  163. /// </summary>
  164. private void PublicFunctionRows()
  165. {
  166. string StrColumnName = "ID,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Hdr_DoorTime)) as 上门日期,Hdr_DoorPeriod as 上门时间,case when Hdr_HomeState = 0 then '未上门' else 'OK' end as 上门状态," +
  167. "Hdr_DoorPersonOne as 上门人员1,Hdr_DoorPersonTwo as 上门人员2,Hdr_DoorPersonThree as 上门人员3,Hdr_DoorPersonFour as 上门人员4,Hdr_Vehicle as 车辆,Hdr_DispatchDoorRemark AS 备注";
  168. DataTable dt = orbll.GetView_Custom("tb_ErpHospitalDispatchDoor", StrWhere: "Hdr_Number = '" + this.txtNumber.Text.Trim() + "'", ShowColumnName: StrColumnName).Tables[0];
  169. this.dgvData.DataSource(dt, strHideField: "ID");
  170. this.dgvData.ClearSelection();
  171. }
  172. }
  173. }