TakePiecesReservationSmallForm.cs 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  1. using LYFZ.Software.MainBusiness.DoorCityProcess;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace LYFZ.Software.MainBusiness.CameraControlBook.SmallForm
  13. {
  14. public partial class TakePiecesReservationSmallForm : LYFZ.Software.UI.CameraControlBook.SmallForm.TakePiecesReservationSmallForm
  15. {
  16. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  17. LYFZ.BLL.BLL_ErpOrderProductList opbll = new BLL.BLL_ErpOrderProductList();
  18. LYFZ.BLL.BLL_ErpOrderWorkAnPaiRecord ordwr = new BLL.BLL_ErpOrderWorkAnPaiRecord();
  19. LYFZ.BLL.BLL_ErpSystemConfigure scbll = new LYFZ.BLL.BLL_ErpSystemConfigure();
  20. public TakePiecesReservationSmallForm()
  21. {
  22. this.Shown += TakePiecesReservationSmallForm_Shown;
  23. this.btnSave.Click += btnSave_Click;
  24. this.lstTextQuery.MouseDoubleClick += lstTextQuery_MouseDoubleClick;
  25. this.lstTextQuery.KeyDown += lstTextQuery_KeyDown;
  26. this.txtTextQuery.EventTextBoxEx_TextChanged += txtTextQuery_EventTextBoxEx_TextChanged;
  27. this.txtTextQuery.Enter += txtTextQuery_Enter;
  28. this.txtTextQuery.KeyDown += txtTextQuery_KeyDown;
  29. this.txtTextQuery.Leave += txtTextQuery_Leave;
  30. this.cmbtreevStoreName.Leave += cmbtreevStoreName_Leave;
  31. this.cmbtreevStoreName.IsNodeMouseClick = true;
  32. this.cmbtreevStoreName.AfterSelectLevelFirstNode = true;
  33. this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
  34. this.mskdgv.Leave += mskdgv_Leave;
  35. this.cmbtreevdgv.Leave += cmbtreevdgv_Leave;
  36. this.dtpcdgv.Leave += dtpcdgv_Leave;
  37. this.txtdgv.Leave += txtdgv_Leave;
  38. this.btnQuery.Click += btnQuery_Click;
  39. this.dgvData.DataGridViewConMenu_ItemClicked += dgvData_DataGridViewConMenu_ItemClicked;
  40. this.dgvData.CellMouseDown += dgvData_CellMouseDown;
  41. this.cmbtreevPhotographName.ComboBoxTree_NodeMouseClick += cmbtreevPhotographName_ComboBoxTree_NodeMouseClick;
  42. this.btn_PickUpSetting.Click += btn_PickUpSetting_Click;
  43. //this.tb_MaxPickUpCount.EventTextBoxEx_TextChanged += tb_MaxPickUpCount_EventTextBoxEx_TextChanged;
  44. BindSystemConfigData();
  45. if (LYFZSS.SystemSpecterPossessed.IsNewCameraControlBook())
  46. {
  47. this.labelEx2.Hide();
  48. this.tb_MaxPickUpCount.Hide();
  49. this.btn_PickUpSetting.Hide();
  50. }
  51. else
  52. {
  53. this.labelEx2.Show();
  54. this.tb_MaxPickUpCount.Show();
  55. this.btn_PickUpSetting.Show();
  56. }
  57. }
  58. Model.CameraTimeTemplate currentSelectCameraTime = null;
  59. /// <summary>
  60. /// 当前选择的档期
  61. /// </summary>
  62. public Model.CameraTimeTemplate CurrentSelectCameraTime { get => currentSelectCameraTime; set => currentSelectCameraTime = value; }
  63. //设置
  64. void btn_PickUpSetting_Click( object sender, EventArgs e )
  65. {
  66. LYFZ.Model.Model_ErpSystemConfigure model = scbll.GetModel( "Sconfig_Code", "DayRemindByPickUp" );
  67. if ( MessageBoxCustom.Show( "是否设置客人每日最大取件量提醒?", "提示", MessageBoxButtons.YesNo ) == System.Windows.Forms.DialogResult.Yes )
  68. {
  69. if ( model == null || model.ID == 0 )
  70. {
  71. model = new Model.Model_ErpSystemConfigure();
  72. }
  73. model.Sconfig_Code = "DayRemindByPickUp";
  74. model.Sconfig_Name = "每日最大取件量";
  75. model.Sconfig_Value = tb_MaxPickUpCount.Text;
  76. model.Sconfig_IsEnabled = true;
  77. model.Sconfig_Remark = "当日预约取件客人超过多少时提醒";
  78. model.Sconfig_Type = "";
  79. model.Sconfig_Order = 1;
  80. model.Sconfig_CreateDatetime = SDateTime.Now;
  81. model.Sconfig_CreateName = "";
  82. if ( model.ID == 0 )
  83. {
  84. scbll.Add( model );
  85. }
  86. else
  87. {
  88. scbll.Update( model );
  89. }
  90. MessageBoxCustom.Show( "每日最大取件量设置成功!" );
  91. }
  92. }
  93. /// <summary>
  94. /// 主订单号
  95. /// </summary>
  96. public string OrdNumber;
  97. /// <summary>
  98. /// 副订单号
  99. /// </summary>
  100. public string OrdViceNumber;
  101. /// <summary>
  102. /// 是否保存
  103. /// </summary>
  104. public bool IsSave = false;
  105. /// <summary>
  106. /// 首次运行 true是,false不是
  107. /// </summary>
  108. bool IsFirstRun = true;
  109. /// <summary>
  110. /// 重新安排
  111. /// </summary>
  112. bool IsUpdateAnPai = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CameraControlBook, LYFZ.CustomAttributes.OperatingAuthority.CameraControlBook_TakePiecesClientAnPaiUpdate );
  113. /// <summary>
  114. /// 窗体加载事件
  115. /// </summary>
  116. /// <param name="sender"></param>
  117. /// <param name="e"></param>
  118. void TakePiecesReservationSmallForm_Shown( object sender, EventArgs e )
  119. {
  120. if (this.currentSelectCameraTime != null)
  121. {
  122. this.lbSelectDateInfo.Text = this.currentSelectCameraTime.GetCameraTimeInfo(LYFZ.DAL.DAL_ErpCompanyInfo.ToShopIDToShopName(this.currentSelectCameraTime.DayTemplate.ShopID), String.Format("{0} {1}", this.currentSelectCameraTime.DayTemplate.CameraDateTime.JavaScriptTimeStampToDateTime().ToYYYY_MM_dd(), this.currentSelectCameraTime.CameraTime));
  123. }
  124. else
  125. {
  126. this.lbSelectDateInfo.Text = "";
  127. }
  128. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindStoreNameALL( this.cmbtreevStoreName, IsShowAllText: false );
  129. if ( !LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CameraControlBook, LYFZ.CustomAttributes.OperatingAuthority.CameraControlBook_TakePiecesClientAnPai ) )
  130. {
  131. this.btnSave.Enabled = false;
  132. }
  133. #region 预约查询
  134. if ( !string.IsNullOrEmpty( this.OrdNumber ) )
  135. {
  136. this.panelEx3.Visible = false;
  137. this.panelEx2.Height = this.panelEx1.Size.Height - 4;
  138. this.GetOrdNumberGetData();
  139. }
  140. this.panelEx2.Visible = true;
  141. #endregion
  142. this.DataRemind();
  143. this.IsFirstRun = false;
  144. }
  145. void BindSystemConfigData()
  146. {
  147. if (LYFZSS.SystemSpecterPossessed.IsNewCameraControlBook())
  148. {
  149. this.tb_MaxPickUpCount.Text = "999999999";
  150. }
  151. else
  152. {
  153. LYFZ.Model.Model_ErpSystemConfigure model = scbll.GetModel( "Sconfig_Code", "DayRemindByPickUp" );
  154. if ( model.ID > 0 && !string.IsNullOrEmpty( model.Sconfig_Value ) )
  155. {
  156. this.tb_MaxPickUpCount.Text = model.Sconfig_Value;
  157. }
  158. }
  159. }
  160. bool CheckSystemConfigDataControl()
  161. {
  162. bool b = true;
  163. if (LYFZSS.SystemSpecterPossessed.IsNewCameraControlBook())
  164. {
  165. return true;
  166. }
  167. else
  168. {
  169. LYFZ.Model.Model_ErpSystemConfigure model = scbll.GetModel( "Sconfig_Code", "DayRemindByPickUp" );
  170. if ( model.ID > 0 && !string.IsNullOrEmpty( model.Sconfig_Value ) )
  171. {
  172. List<string> dateTimeList = new List<string>();
  173. var dgvRowList = this.dgvData.Rows;
  174. foreach ( DataGridViewRow dr in dgvRowList )
  175. {
  176. string datatime = dr.Cells["取件日期"].Value.ToString().Trim();
  177. if ( string.IsNullOrEmpty( datatime ) )
  178. {
  179. continue;
  180. }
  181. if ( !dateTimeList.Contains( datatime ) )
  182. {
  183. dateTimeList.Add( datatime );
  184. }
  185. }
  186. DataTable pickUpData = opbll.GetProductPickUpData( dateTimeList, OrdNumber );
  187. string infoData = "";
  188. foreach ( string dr in dateTimeList )
  189. {
  190. DataRow[] drList = pickUpData.Select( " dataTime = '" + dr + "' " );
  191. if ( drList.Length >= Convert.ToInt32( model.Sconfig_Value ) && Convert.ToInt32( model.Sconfig_Value ) > 0 )
  192. {
  193. infoData += "" + dr + "已预约取件" + drList.Length + "个订单 ,已经达到单日最高取件数" + model.Sconfig_Value + " \r\n";
  194. b = false;
  195. }
  196. }
  197. if ( !string.IsNullOrEmpty( infoData ) )
  198. {
  199. MessageBoxCustom.Show( infoData );
  200. }
  201. }
  202. }
  203. return b;
  204. }
  205. LYFZ.BLL.ReservationTimeData timeDataBll = new BLL.ReservationTimeData();
  206. /// <summary>
  207. /// 保存
  208. /// </summary>
  209. /// <param name="sender"></param>
  210. /// <param name="e"></param>
  211. void btnSave_Click( object sender, EventArgs e )
  212. {
  213. if ( !CheckSystemConfigDataControl() )
  214. {
  215. return;
  216. }
  217. if ( this.dgvData.Rows.Count > 0 )
  218. {
  219. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  220. DateTime strTime = SDateTime.Now;
  221. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  222. List<Model.ReservtionParameter> cameraParameterList = new List<Model.ReservtionParameter>();
  223. for ( int i = 0; i < this.dgvData.Rows.Count; i++ )
  224. {
  225. if ( this.dgvData.Rows[i].Tag != null )
  226. {
  227. LYFZ.Model.Model_ErpOrderProductList model = opbll.GetModel( Convert.ToInt32( this.dgvData.Rows[i].Cells["ID"].Value ) );
  228. if ( string.IsNullOrEmpty( model.OPlist_ViceNumber ) )
  229. {
  230. model.OPlist_ViceNumber = this.OrdViceNumber;
  231. }
  232. DateTime updataTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
  233. if (!String.IsNullOrEmpty(Convert.ToString(this.dgvData.Rows[i].Cells["取件日期"].Tag)) && !String.IsNullOrEmpty(Convert.ToString(this.dgvData.Rows[i].Cells["取件时间"].Tag)))
  234. {
  235. updataTime = Convert.ToDateTime(this.dgvData.Rows[i].Cells["取件日期"].Tag + " " + this.dgvData.Rows[i].Cells["取件时间"].Tag);
  236. }
  237. else if (!String.IsNullOrEmpty(Convert.ToString(this.dgvData.Rows[i].Cells["取件日期"].Tag)) && String.IsNullOrEmpty(Convert.ToString(this.dgvData.Rows[i].Cells["取件时间"].Tag)))
  238. {
  239. updataTime = Convert.ToDateTime(this.dgvData.Rows[i].Cells["取件日期"].Tag);
  240. }
  241. if ( this.dgvData.Rows[i].Cells["取件日期"].Value.ToString().Trim() != "" && this.dgvData.Rows[i].Cells["取件时间"].Value.ToString().Trim() != "" )
  242. {
  243. model.OPlist_ReservationTakeTime = Convert.ToDateTime( this.dgvData.Rows[i].Cells["取件日期"].Value + " " + this.dgvData.Rows[i].Cells["取件时间"].Value );
  244. }
  245. else if ( this.dgvData.Rows[i].Cells["取件日期"].Value.ToString().Trim() != "" )
  246. {
  247. model.OPlist_ReservationTakeTime = Convert.ToDateTime( this.dgvData.Rows[i].Cells["取件日期"].Value );
  248. }
  249. else { model.OPlist_ReservationTakeTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
  250. if ( this.dgvData.Rows[i].Cells["取件人"].Tag != null )
  251. {
  252. model.OPlist_ReservationTakeName = this.dgvData.Rows[i].Cells["取件人"].Tag.ToString().Trim();
  253. }
  254. else
  255. {
  256. model.OPlist_ReservationTakeName = "";
  257. }
  258. //// if (string.IsNullOrEmpty(model.OPlist_ReservationTakeDividedShop))
  259. //{ model.OPlist_ReservationTakeDividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); }
  260. if ( this.dgvData.Rows[i].Cells["取件门店"].Tag != null )
  261. {
  262. model.OPlist_ReservationTakeDividedShop = this.dgvData.Rows[i].Cells["取件门店"].Tag.ToString();
  263. }
  264. else
  265. {
  266. model.OPlist_ReservationTakeDividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  267. }
  268. model.OPlist_ExpeditedTime = model.OPlist_ReservationTakeTime;
  269. model.OPlist_ArrangeTime = strTime;
  270. model.OPlist_ArrangeNmae = strUserID;
  271. model.OPlist_ArrangeRemark = this.dgvData.Rows[i].Cells["预约说明"].Value.ToString().Trim();
  272. model.OPlist_UpdateDateTime = strTime;
  273. model.OPlist_UpdateName = strUserID;
  274. clist.Add( opbll.GetUpdateCommandInfo( model ) );
  275. #region 设置模板预约
  276. cameraParameterList.Add(new Model.ReservtionParameter
  277. {
  278. ShopID = model.OPlist_ReservationTakeDividedShop
  279. ,
  280. DayDate = this.dgvData.Rows[i].Cells["取件日期"].Value.ToString().Trim()
  281. ,
  282. Time = this.dgvData.Rows[i].Cells["取件时间"].Value.ToString().Trim()
  283. ,
  284. VID = model.ID.ToString()
  285. });
  286. #endregion
  287. LYFZ.Model.Model_ErpOrderProductList modelnew = opbll.GetModel( Convert.ToInt32( this.dgvData.Rows[i].Cells["ID"].Value ) );
  288. if ( !modelnew.OPlist_ReservationTakeName.Equals( model.OPlist_ReservationTakeName ) ||
  289. !modelnew.OPlist_ReservationTakeTime.Equals( model.OPlist_ReservationTakeTime ) ||
  290. !modelnew.OPlist_ReservationTakeDividedShop.Equals( model.OPlist_ReservationTakeDividedShop ) )
  291. {
  292. string storaRecord = "";
  293. if ( this.dgvData.Rows[i].Cells["取件门店"].Value.ToString().Trim() != "" )
  294. {
  295. storaRecord = "门店:" + this.dgvData.Rows[i].Cells["取件门店"].Value.ToString().Trim() + " ";
  296. }
  297. LYFZ.Model.Model_ErpOrderWorkAnPaiRecord modelRecord = new Model.Model_ErpOrderWorkAnPaiRecord();
  298. modelRecord.Ordwr_Number = "OWPR_" + LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  299. modelRecord.Ordwr_WorkNumber = model.ID.ToString().Trim();
  300. modelRecord.Ordwr_OrdNumber = model.OPlist_OrderNumber;
  301. modelRecord.Ordwr_ViceNumber = model.OPlist_ViceNumber;
  302. modelRecord.Ordwr_ModuleName = LYFZ.EnumPublic.WorkAnPaiChangeLogEnum.摄控安排取件客人.ToString();
  303. modelRecord.Ordwr_UpdateOrderName = model.OPlist_PickupName;
  304. modelRecord.Ordwr_UpdateAgoPerson = model.OPlist_ArrangeNmae;
  305. modelRecord.Ordwr_UpdateAgoTime = model.OPlist_ArrangeTime;
  306. modelRecord.Ordwr_UpdateAgoData = storaRecord + "取件时间:" +
  307. ((updataTime != model.OPlist_ReservationTakeTime && LYFZ.BLL.OtherCommonModel.DateTimeToString(updataTime) != "") ? "原日期" + updataTime + " 修改为日期" +
  308. LYFZ.BLL.OtherCommonModel.DateTimeToString(model.OPlist_ReservationTakeTime) : LYFZ.BLL.OtherCommonModel.DateTimeToString(model.OPlist_ReservationTakeTime))
  309. + " 取件师:" + LYFZ.BLL.BLL_ErpOrderView.GetUserName( model.OPlist_ReservationTakeName );
  310. modelRecord.Ordwr_CreateDatetime = strTime;
  311. modelRecord.Ordwr_CreateName = strUserID;
  312. clist.Add( ordwr.GetAddCommandInfo( modelRecord ) );
  313. }
  314. }
  315. }
  316. if ( clist.Count > 0 )
  317. {
  318. string retErrorMsg = "";
  319. if (!this.timeDataBll.UpdateReservationTimeDataCommandInfoList(OrdNumber, this.txtOrderNumber.Text, Model.CameraType.取件客人, this.GetCameraOrderType(), cameraParameterList, ref clist, ref retErrorMsg))
  320. {
  321. MessageBoxCustom.Show(String.Format("保存预约失败:{0}", retErrorMsg));
  322. return;
  323. }
  324. if ( MessageBoxCustom.Show( "您确定要保存此操作吗?", "温馨提示", MessageBoxButtons.YesNo ) == DialogResult.Yes )
  325. {
  326. if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( clist ) > 0 )
  327. {
  328. this.IsSave = true;
  329. MessageBoxCustom.Show( "保存成功" );
  330. }
  331. else
  332. {
  333. MessageBoxCustom.Show( "保存失败" );
  334. }
  335. }
  336. }
  337. else
  338. {
  339. MessageBoxCustom.Show( "没有做任何修改!无须保存" ); return;
  340. }
  341. }
  342. }
  343. /// <summary>
  344. /// 列表事件双击
  345. /// </summary>
  346. /// <param name="sender"></param>
  347. /// <param name="e"></param>
  348. void lstTextQuery_MouseDoubleClick( object sender, MouseEventArgs e )
  349. {
  350. if ( lstTextQuery.Items.Count > 0 )
  351. {
  352. if ( ((ListItem)this.lstTextQuery.SelectedItem) != null )
  353. {
  354. this.OrdNumber = ((ListItem)this.lstTextQuery.SelectedItem).StrValue.ToString().Trim();
  355. this.GetOrdNumberGetData();
  356. this.DataRemind();
  357. this.txtTextQuery.Text = ((ListItem)this.lstTextQuery.SelectedItem).StrText;
  358. }
  359. }
  360. this.lstTextQuery.Visible = false;
  361. }
  362. /// <summary>
  363. /// 按回车键
  364. /// </summary>
  365. /// <param name="sender"></param>
  366. /// <param name="e"></param>
  367. void lstTextQuery_KeyDown( object sender, KeyEventArgs e )
  368. {
  369. if ( e.KeyCode == Keys.Enter )
  370. {
  371. this.lstTextQuery_MouseDoubleClick( this, null );
  372. }
  373. }
  374. /// <summary>
  375. /// 输入值变化
  376. /// </summary>
  377. /// <param name="sender"></param>
  378. /// <param name="e"></param>
  379. void txtTextQuery_EventTextBoxEx_TextChanged( object sender, EventArgs e )
  380. {
  381. if ( !this.IsFirstRun )
  382. {
  383. if ( this.txtTextQuery.Text.Trim() == "" )
  384. {
  385. this.lstTextQuery.Visible = true;
  386. }
  387. }
  388. }
  389. /// <summary>
  390. /// 点击输入框
  391. /// </summary>
  392. /// <param name="sender"></param>
  393. /// <param name="e"></param>
  394. void txtTextQuery_Enter( object sender, EventArgs e )
  395. {
  396. this.txtTextQuery_EventTextBoxEx_TextChanged( null, null );
  397. }
  398. /// <summary>
  399. /// 查询
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. void btnQuery_Click( object sender, EventArgs e )
  404. {
  405. LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient( this.txtTextQuery, this.lstTextQuery, cameraType: Model.CameraType.取件客人);
  406. }
  407. /// <summary>
  408. /// 按键盘上的下健时
  409. /// </summary>
  410. /// <param name="sender"></param>
  411. /// <param name="e"></param>
  412. void txtTextQuery_KeyDown( object sender, KeyEventArgs e )
  413. {
  414. if ( e.KeyCode == Keys.Down || e.KeyCode == Keys.Up )
  415. {
  416. if (this.lstTextQuery.Items.Count > 0)
  417. {
  418. this.lstTextQuery.SelectedIndex = 0; this.lstTextQuery.Focus();
  419. }
  420. }
  421. else if ( e.KeyCode == Keys.Enter )
  422. {
  423. LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient( this.txtTextQuery, this.lstTextQuery, cameraType: Model.CameraType.取件客人);
  424. }
  425. }
  426. /// <summary>
  427. /// 查询文本框离开事件
  428. /// </summary>
  429. /// <param name="sender"></param>
  430. /// <param name="e"></param>
  431. void txtTextQuery_Leave( object sender, EventArgs e )
  432. {
  433. if ( !this.lstTextQuery.Focused )
  434. {
  435. this.lstTextQuery.Visible = false;
  436. }
  437. }
  438. /// <summary>
  439. /// 拍照名称
  440. /// </summary>
  441. /// <param name="sender"></param>
  442. /// <param name="e"></param>
  443. void cmbtreevPhotographName_ComboBoxTree_NodeMouseClick( object sender, TreeNodeMouseClickEventArgs e )
  444. {
  445. this.OrdViceNumber = this.cmbtreevPhotographName.Tag.ToString().Trim();
  446. this.DataRemind();
  447. }
  448. string StrOrderType = "";
  449. /// <summary>
  450. /// 查询获取订单信息
  451. /// </summary>
  452. void GetOrdNumberGetData()
  453. {
  454. string StrTableName = "select Ord_DividedShop," +
  455. "Ordv_ViceNumber," +
  456. "Ordv_ReservationFilmSelectionName," +
  457. "Ordv_ReservationFilmSelectionTime," +
  458. "Cus_Name," +
  459. "Cus_Sex_cs," +
  460. "Ord_SinceOrderNumber," +
  461. "Ord_SeriesName," +
  462. "Ord_SeriesPrice," +
  463. "Ordv_IntoRegisterQuantity," +
  464. "Ordv_IntoBottomQuantity," +
  465. "Ord_Type," +
  466. "Ord_OrderPersonName," +
  467. "Ordpg_Sights ,Ordpg_Sights as Ords_SightsName " +
  468. "from tb_ErpOrder " +
  469. "Left Join tb_ErpOrderDigital ON Ord_Number = Ordv_Number " +
  470. "Left Join tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber " +
  471. "Left Join [tb_ErpOrdersPhotography] on Ordpg_ViceNumber = Ordv_ViceNumber " +
  472. "Where Ordv_Number = '" + this.OrdNumber + "' Order By Ordv_DigitalNumber";
  473. DataTable tbl = orbll.GetView_Custom( StrTableName ).Tables[0];
  474. if ( tbl.Rows.Count > 0 )
  475. {
  476. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsWithinSchedule)
  477. {
  478. if (this.currentSelectCameraTime != null)
  479. {
  480. if (tbl.Rows[0]["Ord_Type"].ToString().Trim() != this.currentSelectCameraTime.DayTemplate.OrderType.ToString())
  481. {
  482. MessageBoxCustom.Show(this.currentSelectCameraTime.GetPromptInfo());
  483. this.OrdNumber = "";
  484. this.OrdViceNumber = "";
  485. return;
  486. }
  487. }
  488. }
  489. this.txtOrderNumber.Text = tbl.Rows[0]["Ord_SinceOrderNumber"].ToString().Trim();
  490. this.txtSeriesName.Text = tbl.Rows[0]["Ord_SeriesName"].ToString().Trim();
  491. this.txtOrdersPerson.Text = tbl.Rows[0]["Ord_OrderPersonName"].ToString().Trim();
  492. this.SetClientData( tbl.Rows[0]["Cus_Name"].ToString().Trim(), tbl.Rows[0]["Cus_Sex_cs"].ToString().Trim(), tbl.Rows[0]["Ord_Type"].ToString().Trim() );
  493. //LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.SetClientData(this.txtName1, this.txtName2, lblName1, lblName2, tbl.Rows[0]["Ord_Type"].ToString().Trim(), tbl.Rows[0]["Cus_Name"].ToString().Trim(), tbl.Rows[0]["Cus_Sex_cs"].ToString().Trim(), -23);
  494. this.StrOrderType = tbl.Rows[0]["Ord_Type"].ToString().Trim();
  495. if (this.StrOrderType == "1")
  496. {
  497. this.labelEx10.Show();
  498. this.cmbtreevPhotographName.Show();
  499. }
  500. else {
  501. this.labelEx10.Hide();
  502. this.cmbtreevPhotographName.Hide();
  503. }
  504. this.cmbtreevPhotographName.Nodes.Clear();
  505. TreeNode root = null;
  506. for ( int i = 0; i < tbl.Rows.Count; i++ )
  507. {
  508. root = new TreeNode();
  509. root.Name = tbl.Rows[i]["Ordv_ViceNumber"].ToString().Trim();
  510. root.Text = tbl.Rows[i]["Ords_SightsName"].ToString().Trim();
  511. root.Tag = tbl.Rows[i]["Ordv_ViceNumber"].ToString().Trim();
  512. this.cmbtreevPhotographName.Nodes.Add( root );
  513. }
  514. this.cmbtreevPhotographName.TagFindText( tbl.Rows[0]["Ordv_ViceNumber"].ToString().Trim() );
  515. this.OrdViceNumber = tbl.Rows[0]["Ordv_ViceNumber"].ToString().Trim();
  516. this.tx_serial_price.Text = tbl.Rows[0]["Ord_SeriesPrice"].ToString().Trim();
  517. this.tx_rdrc.Text = string.Format( "{0}\\{1}", tbl.Rows[0]["Ordv_IntoBottomQuantity"].ToString().Trim(), tbl.Rows[0]["Ordv_IntoRegisterQuantity"].ToString().Trim() );
  518. if ( tbl.Rows[0]["Ord_DividedShop"].ToString().Trim() != LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID() )
  519. {
  520. if ( MessageBoxCustom.Show( "'" + tbl.Rows[0]["Ord_SinceOrderNumber"].ToString().Trim() + "'订单不属于本店所开,是否要继续安排?", "温馨提示", MessageBoxButtons.YesNo ) == DialogResult.No )
  521. {
  522. return;
  523. }
  524. }
  525. }
  526. }
  527. /// <summary>
  528. /// 设计加载的项
  529. /// </summary>
  530. /// <param name="StrName"></param>
  531. /// <param name="StrSex"></param>
  532. /// <param name="StrOrderType"></param>
  533. void SetClientData( string StrName, string StrSex, string StrOrderType )
  534. {
  535. string[] StrNameArray = StrName.Trim().Split( '/' );
  536. string[] StrSexArray = StrSex.Trim().Split( '/' );
  537. if ( StrOrderType.Trim() == "0" )
  538. {
  539. if ( StrNameArray.Length > 1 )
  540. {
  541. if ( StrSexArray[0].Trim() == "男" )
  542. {
  543. lblName1.Text = "男宾姓名:";
  544. }
  545. else if ( StrSexArray[0].Trim() == "女" )
  546. {
  547. lblName1.Text = "女宾姓名:";
  548. }
  549. txtName1.Text = StrNameArray[0].Trim();
  550. if ( StrSexArray[1].Trim() == "男" )
  551. {
  552. lblName2.Text = "男宾姓名:";
  553. }
  554. else if ( StrSexArray[1].Trim() == "女" )
  555. {
  556. lblName2.Text = "女宾姓名:";
  557. }
  558. txtName2.Text = StrNameArray[1].Trim();
  559. }
  560. else
  561. {
  562. lblName1.Text = "男宾姓名:";
  563. lblName2.Text = "女宾姓名:";
  564. if ( StrSexArray[0].Trim() == "男" )
  565. {
  566. txtName1.Text = StrNameArray[0].Trim();
  567. }
  568. else if ( StrSexArray[0].Trim() == "女" )
  569. {
  570. txtName2.Text = StrNameArray[0].Trim();
  571. }
  572. }
  573. }
  574. else if ( StrOrderType.Trim() == "1" )
  575. {
  576. lblName1.Text = "宝贝姓名:";
  577. lblName2.Text = "家长姓名:";
  578. txtName1.Text = StrNameArray[0].Trim();
  579. if (StrNameArray.Length > 1)
  580. {
  581. txtName2.Text = StrNameArray[1].Trim();
  582. }
  583. else
  584. {
  585. txtName2.Text = StrNameArray[0].Trim();
  586. }
  587. }
  588. else if ( StrOrderType.Trim() == "2" )
  589. {
  590. lblName1.Text = "客户姓名:";
  591. lblName2.Text = "客户性别:";
  592. txtName1.Text = StrNameArray[0].Trim();
  593. txtName2.Text = StrSexArray[0].Trim();
  594. }
  595. else if ( StrOrderType.Trim() == "3" )
  596. {
  597. lblName1.Text = "客户姓名:";
  598. lblName2.Text = "客户性别:";
  599. txtName1.Text = StrNameArray[0].Trim();
  600. txtName2.Text = StrSexArray[0].Trim();
  601. }
  602. //lblName1.Location = new Point(596, lblName1.Location.Y);
  603. //lblName2.Location = new Point(764, lblName1.Location.Y);
  604. }
  605. /// <summary>
  606. /// 加载当日已预约的客人
  607. /// </summary>
  608. /// <param name="StrType"></param>
  609. void DataRemind()
  610. {
  611. string strWhere = "";
  612. int strTop = -1;
  613. if ( !string.IsNullOrEmpty( this.OrdViceNumber ) )
  614. {
  615. if ( this.StrOrderType == "1" )
  616. {
  617. strWhere = " And ((OPlist_OrderNumber ='" + this.OrdNumber + "' and OPlist_ViceNumber = '') or OPlist_ViceNumber = '" + this.OrdViceNumber + "' )";
  618. }
  619. else
  620. {
  621. strWhere = " And OPlist_OrderNumber ='" + this.OrdNumber + "'";
  622. }
  623. }
  624. else
  625. {
  626. strTop = 0;
  627. }
  628. string strColumnName = "tb_ErpOrderProductList.ID, OPlist_ViceNumber, OPlist_ProdNumber AS 商品编号, OPlist_ProdName AS 商品名称, dbo.fn_CheckTakePiecesStatus(OPlist_PickupStatus) AS 取件状态, dbo.fn_CheckIsExpedited(OPlist_IsExpedited) AS 加急,Company_Name AS 取件门店,Company_DividedShop AS 门店编号, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS 取件日期, dbo.fn_CheckDateTimeReturn_Time(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS 取件时间, OPlist_ReservationTakeName AS 取件人,User_Name AS 取件师, OPlist_ArrangeRemark AS 预约说明";
  629. DataTable tbl = orbll.GetView_Custom( "tb_ErpOrderProductList Left Join tb_ErpUser on User_EmployeeID = OPlist_ReservationTakeName Left Join tb_ErpCompanyInfo on Company_DividedShop = OPlist_ReservationTakeDividedShop", StrWhere: " OPlist_Type = '2'" + strWhere, filedOrder: "OPlist_ViceNumber ASC", ShowColumnName: strColumnName, TopCount: strTop ).Tables[0];
  630. if ( this.dgvData.Columns.Count <= 0 )
  631. {
  632. for ( int i = 0; i < tbl.Columns.Count; i++ )
  633. {
  634. if ( tbl.Columns[i].ColumnName.Trim() != "取件师" && tbl.Columns[i].ColumnName.Trim() != "门店编号" )
  635. {
  636. DataGridViewColumn dca = new DataGridViewColumn();
  637. dca.HeaderText = tbl.Columns[i].ColumnName.Trim();
  638. dca.Name = tbl.Columns[i].ColumnName.Trim();
  639. if ( dca.Name.Trim() == "ID" || dca.Name.Trim() == "OPlist_ViceNumber" )
  640. {
  641. dca.Visible = false;
  642. }
  643. dca.ReadOnly = true;
  644. this.dgvData.Columns.Add( dca );
  645. }
  646. }
  647. }
  648. this.dgvData.Rows.Clear();
  649. if ( !string.IsNullOrEmpty( this.OrdViceNumber ) )
  650. {
  651. DataGridViewCell cellShopID = null;
  652. DataGridViewCell cellDate = null;
  653. DataGridViewCell cellTime = null;
  654. for ( int i = 0; i < tbl.Rows.Count; i++ )
  655. {
  656. DataGridViewRow dgvl = new DataGridViewRow();
  657. DataGridViewCell cell = null;
  658. for ( int j = 0; j < this.dgvData.Columns.Count; j++ )
  659. {
  660. cell = new DataGridViewTextBoxCell();
  661. switch ( this.dgvData.Columns[j].Name.Trim() )
  662. {
  663. case "取件人":
  664. cell.Value = tbl.Rows[i]["取件师"].ToString().Trim();
  665. cell.Tag = tbl.Rows[i]["取件人"].ToString().Trim();
  666. break;
  667. case "取件门店":
  668. cellShopID = cell;
  669. cell.Value = tbl.Rows[i][this.dgvData.Columns[j].Name].ToString().Trim();
  670. cell.Tag = tbl.Rows[i]["门店编号"].ToString().Trim();
  671. if (cell.Value == null)
  672. {
  673. cell.Value = "";
  674. }
  675. if (cell.Value.ToString() == "")
  676. {
  677. cell.Value = LYFZ.DAL.DAL_ErpCompanyInfo.ToShopIDToShopName(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID());
  678. cell.Tag = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  679. }
  680. break;
  681. case "取件日期":
  682. case "取件时间":
  683. cell.Value = tbl.Rows[i][this.dgvData.Columns[j].Name].ToString().Trim();
  684. cell.Tag = tbl.Rows[i][this.dgvData.Columns[j].Name].ToString().Trim();
  685. if (this.dgvData.Columns[j].Name.Trim() == "取件日期")
  686. {
  687. cellDate = cell;
  688. }
  689. else if (this.dgvData.Columns[j].Name.Trim() == "取件时间")
  690. {
  691. cellTime = cell;
  692. }
  693. break;
  694. default: cell.Value = tbl.Rows[i][this.dgvData.Columns[j].Name.Trim()].ToString().Trim(); break;
  695. }
  696. dgvl.Cells.Add( cell );
  697. }
  698. if (this.currentSelectCameraTime != null && cellShopID != null && cellDate != null && cellTime != null)
  699. {
  700. string photographedDate = "";
  701. if (cellDate.Tag != null)
  702. {
  703. photographedDate = cellDate.Tag.ToString();
  704. }
  705. string pTime = "";
  706. if (cellTime.Tag != null)
  707. {
  708. pTime = cellTime.Tag.ToString();
  709. }
  710. if (String.IsNullOrWhiteSpace(photographedDate) || String.IsNullOrWhiteSpace(pTime))
  711. {
  712. cellShopID.Value = LYFZ.DAL.DAL_ErpCompanyInfo.ToShopIDToShopName(this.currentSelectCameraTime.DayTemplate.ShopID);
  713. cellShopID.Tag = this.currentSelectCameraTime.DayTemplate.ShopID;
  714. cellDate.Value = this.currentSelectCameraTime.DayTemplate.CameraDateTime.JavaScriptTimeStampToDateTime().ToYYYY_MM_dd();
  715. cellDate.Tag = this.currentSelectCameraTime.DayTemplate.CameraDateTime.JavaScriptTimeStampToDateTime().ToYYYY_MM_dd();
  716. cellTime.Value = this.currentSelectCameraTime.CameraTime;
  717. cellTime.Tag = this.currentSelectCameraTime.CameraTime;
  718. dgvl.Tag = "1";
  719. }
  720. }
  721. this.dgvData.Rows.Add( dgvl );
  722. }
  723. DataTable dt = orbll.GetView_Custom( "tb_ErpOrderDigital Left Join CView_OrderPickupStatusVice on OPlist_ViceNumber = Ordv_ViceNumber", StrWhere: "Ordv_ViceNumber = '" + this.OrdViceNumber + "'", ShowColumnName: "取件状态" ).Tables[0];
  724. if ( dt.Rows[0]["取件状态"].ToString().Trim() == "OK" )
  725. {
  726. string StrMaengd = "订单取件已完成";
  727. StrMaengd = "'" + this.cmbtreevPhotographName.Text.Trim() + "'取件已完成!";
  728. MessageBoxCustom.Show( StrMaengd );
  729. this.btnSave.Enabled = false;
  730. }
  731. else
  732. {
  733. this.btnSave.Enabled = true;
  734. }
  735. }
  736. }
  737. /// <summary>
  738. /// 暂存预约选择的档期数据
  739. /// </summary>
  740. Dictionary<int, Model.CameraTimeTemplate> TimeTemplateKeyValues = new Dictionary<int, Model.CameraTimeTemplate>();
  741. Model.CameraOrderType GetCameraOrderType()
  742. {
  743. return (Model.CameraOrderType)Convert.ToInt32(this.StrOrderType);
  744. }
  745. /// <summary>
  746. /// 列表列双击事件
  747. /// </summary>
  748. /// <param name="sender"></param>
  749. /// <param name="e"></param>
  750. void dgvData_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
  751. {
  752. if ( e.RowIndex >= 0 )
  753. {
  754. this.txtdgv.Visible = false;
  755. this.mskdgv.Visible = false;
  756. this.dtpcdgv.Visible = false;
  757. this.cmbtreevdgv.Visible = false;
  758. DataTable dt = orbll.GetView_Custom( "tb_ErpOrderProductList", StrWhere: "ID = '" + this.dgvData.Rows[e.RowIndex].Cells["ID"].Value + "'", ShowColumnName: "OPlist_ReservationTakeDividedShop,OPlist_ReservationTakeName,OPlist_ReservationTakeTime,OPlist_ArrangeRemark" ).Tables[0];
  759. if ( this.dgvData.Columns[e.ColumnIndex].Name == "取件门店" )
  760. {
  761. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeDividedShop"].ToString() ) ) && !IsUpdateAnPai )
  762. {
  763. return;
  764. }
  765. DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex];
  766. Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true );
  767. this.cmbtreevStoreName.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y );
  768. this.cmbtreevStoreName.Size = rect.Size;
  769. this.cmbtreevStoreName.Visible = true;
  770. this.mskdgv.Visible = false;
  771. this.cmbtreevdgv.Visible = false;
  772. this.txtdgv.Visible = false;
  773. this.dtpcdgv.Visible = false;
  774. this.cmbtreevStoreName.TextFindTag( cell.Value.ToString().Trim() );
  775. this.cmbtreevStoreName.StrKey = "F";
  776. this.cmbtreevStoreName.Focus();
  777. }
  778. else if ( this.dgvData.Columns[e.ColumnIndex].Name == "取件日期" )
  779. {
  780. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeTime"].ToString() ) ) && !IsUpdateAnPai )
  781. {
  782. return;
  783. }
  784. DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex];
  785. Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true );
  786. this.dtpcdgv.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y );
  787. this.dtpcdgv.Size = rect.Size;
  788. this.dtpcdgv.DateValue = LYFZ.Command.Command_Validate.DateTimeToString( cell.Value );
  789. this.dtpcdgv.Visible = true;
  790. this.dtpcdgv.Focus();
  791. }
  792. else if ( this.dgvData.Columns[e.ColumnIndex].Name == "取件时间" )
  793. {
  794. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeTime"].ToString() ) ) && LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeTime"].ToString(), "HH:mm" ) != "00:00" && !IsUpdateAnPai )
  795. {
  796. return;
  797. }
  798. if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsWithinSchedule|| !LYFZSS.SystemSpecterPossessed.IsNewCameraControlBook())
  799. {
  800. DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex];
  801. Rectangle rect = this.dgvData.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true);
  802. this.mskdgv.Location = new Point(rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y);
  803. this.mskdgv.Size = rect.Size;
  804. this.mskdgv.Visible = true;
  805. this.mskdgv.Text = (String)cell.Value;
  806. this.mskdgv.Focus();
  807. }
  808. else
  809. {
  810. //选择时间
  811. DateTime dayDate = SDateTime.Now;
  812. string shopID = "";
  813. List<DateTime> dateTimes = GetDateTime();
  814. List<string> selectShopIDs = GetSelectShopID();
  815. if (dateTimes.Count > 0)
  816. {
  817. dayDate = dateTimes[0];
  818. }
  819. if (selectShopIDs.Count > 0)
  820. {
  821. shopID = selectShopIDs[0];
  822. }
  823. if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition)
  824. {
  825. if (selectShopIDs.Count <= 0)
  826. {
  827. MessageBoxCustom.Show("需要先选择要预约的门店");
  828. return;
  829. }
  830. }
  831. if (dateTimes.Count <= 0)
  832. {
  833. MessageBoxCustom.Show("需要先选择取件日期");
  834. return;
  835. }
  836. Model.CameraTimeTemplate cameraTime = PhotographedReservationSmallForm.GetCameraTime(dayDate, shopID, Model.CameraType.取件客人, this.GetCameraOrderType());
  837. if (cameraTime != null)
  838. {
  839. DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex];
  840. cell.Value = cameraTime.CameraTime;
  841. if (TimeTemplateKeyValues.ContainsKey(e.RowIndex))
  842. {
  843. this.TimeTemplateKeyValues.Remove(e.RowIndex);
  844. }
  845. this.TimeTemplateKeyValues.Add(e.RowIndex, cameraTime);
  846. this.dgvData.Rows[e.RowIndex].Tag = "1";
  847. }
  848. }
  849. }
  850. else if ( this.dgvData.Columns[e.ColumnIndex].Name == "取件人" )
  851. {
  852. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeName"].ToString() ) ) && !IsUpdateAnPai )
  853. {
  854. return;
  855. }
  856. LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.SelectWorkPersonSuperSmallForm frm = new SuperSmallForm.SelectWorkPersonSuperSmallForm();
  857. frm.StrTime = this.dgvData.CurrentRow.Cells["取件日期"].Value.ToString().Trim();
  858. frm.WorkPersonType = LYFZ.EnumPublic.EnumWorkPersonType.取件师;
  859. frm.ShowDialog();
  860. if ( frm.IsSaveed )
  861. {
  862. this.dgvData.CurrentRow.Cells[e.ColumnIndex].Value = frm.StrPersonName;
  863. this.dgvData.CurrentRow.Cells[e.ColumnIndex].Tag = frm.StrPersonNumber;
  864. this.dgvData.CurrentRow.Tag = "1";
  865. }
  866. }
  867. else if ( this.dgvData.Columns[e.ColumnIndex].Name == "预约说明" )
  868. {
  869. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ArrangeRemark"].ToString() ) ) && !IsUpdateAnPai )
  870. {
  871. return;
  872. }
  873. DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex];
  874. Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true );
  875. this.txtdgv.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y - 1 );
  876. this.txtdgv.Size = rect.Size;
  877. this.txtdgv.Text = cell.Value.ToString();
  878. this.txtdgv.Tag = "BZ";
  879. this.txtdgv.Visible = true;
  880. this.txtdgv.Focus();
  881. }
  882. }
  883. }
  884. /// <summary>
  885. /// 选择门店
  886. /// </summary>
  887. /// <param name="sender"></param>
  888. /// <param name="e"></param>
  889. void cmbtreevStoreName_Leave( object sender, EventArgs e )
  890. {
  891. if ( this.cmbtreevStoreName.StrKey != null )
  892. {
  893. if ( this.cmbtreevStoreName.StrKey.ToString().Trim() == "F" )
  894. {
  895. if ( this.cmbtreevStoreName.Text.Trim() != "" )
  896. {
  897. this.dgvData.CurrentRow.Cells["取件门店"].Value = this.cmbtreevStoreName.Text.Trim();
  898. this.dgvData.CurrentRow.Cells["取件门店"].Tag = this.cmbtreevStoreName.Tag;
  899. }
  900. else
  901. {
  902. this.dgvData.CurrentRow.Cells["取件门店"].Value = "";
  903. this.dgvData.CurrentRow.Cells["取件门店"].Tag = null;
  904. }
  905. this.dgvData.CurrentRow.Tag = "1";
  906. }
  907. this.cmbtreevStoreName.Visible = false;
  908. if (LYFZSS.SystemSpecterPossessed.IsNewCameraControlBook())
  909. {
  910. if (TimeTemplateKeyValues.ContainsKey(this.dgvData.CurrentRow.Index))
  911. {
  912. if (TimeTemplateKeyValues[this.dgvData.CurrentRow.Index].DayTemplate.ShopID != this.cmbtreevStoreName.Tag.ToString())
  913. {
  914. this.dgvData.CurrentRow.Cells["取件时间"].Value = "";
  915. this.TimeTemplateKeyValues.Remove(this.dgvData.CurrentRow.Index);
  916. }
  917. }
  918. else
  919. {
  920. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsWithinSchedule)
  921. {
  922. this.dgvData.CurrentRow.Cells["取件时间"].Value = "";
  923. }
  924. }
  925. }
  926. }
  927. }
  928. /// <summary>
  929. /// 时间控件离开事件
  930. /// </summary>
  931. /// <param name="sender"></param>
  932. /// <param name="e"></param>
  933. void mskdgv_Leave( object sender, EventArgs e )
  934. {
  935. if ( this.mskdgv.Text.Trim() != ":" )
  936. {
  937. try
  938. {
  939. DateTime strts = Convert.ToDateTime( SDateTime.Now.ToString( "yyyy-MM-dd" ) + " " + this.mskdgv.Text.Trim() );
  940. this.dgvData.CurrentRow.Cells["取件时间"].Value = this.mskdgv.Text.Trim();
  941. }
  942. catch
  943. {
  944. MessageBoxCustom.Show( "不是有效的时间格式" ); this.mskdgv.Text = ""; this.mskdgv.Focus(); return;
  945. }
  946. }
  947. else
  948. {
  949. this.dgvData.CurrentRow.Cells["取件时间"].Value = "";
  950. }
  951. this.dgvData.CurrentRow.Tag = "1";
  952. this.mskdgv.Visible = false;
  953. }
  954. /// <summary>
  955. /// 日期控件失去焦点
  956. /// </summary>
  957. /// <param name="sender"></param>
  958. /// <param name="e"></param>
  959. void dtpcdgv_Leave( object sender, EventArgs e )
  960. {
  961. if ( this.dgvData.CurrentCell.ColumnIndex == this.dgvData.Columns["取件日期"].Index )
  962. {
  963. if ( this.dtpcdgv.DateValue.Trim() != "" )
  964. {
  965. if ( !string.IsNullOrEmpty( this.dgvData.CurrentRow.Cells["取件人"].Value.ToString().Trim() ) )
  966. {
  967. if ( this.dgvData.CurrentRow.Cells["取件人"].Tag != null )
  968. {
  969. if ( LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetRestPerson( this.dtpcdgv.DateValue.Trim(), this.dgvData.CurrentRow.Cells["取件人"].Tag.ToString().Trim() ) )
  970. {
  971. MessageBoxCustom.Show( this.dgvData.CurrentRow.Cells["取件人"].Value.ToString().Trim() + " '" + this.dtpcdgv.DateValue.Trim() + "'休息,不能安排工作!" );
  972. this.dtpcdgv.DateValue = "";
  973. this.dtpcdgv.Focus();
  974. return;
  975. }
  976. }
  977. }
  978. this.dgvData.CurrentRow.Cells["取件日期"].Value = this.dtpcdgv.DateValue.Trim();
  979. }
  980. else
  981. {
  982. this.dgvData.CurrentRow.Cells["取件日期"].Value = "";
  983. }
  984. this.dgvData.CurrentRow.Tag = "1";
  985. }
  986. this.dtpcdgv.Text = "";
  987. this.dtpcdgv.Visible = false;
  988. }
  989. /// <summary>
  990. /// 取件人离开事件
  991. /// </summary>
  992. /// <param name="sender"></param>
  993. /// <param name="e"></param>
  994. void cmbtreevdgv_Leave( object sender, EventArgs e )
  995. {
  996. if ( this.cmbtreevdgv.StrKey != null )
  997. {
  998. if ( this.cmbtreevdgv.StrKey.ToString().Trim() == "QJ" )
  999. {
  1000. if ( this.cmbtreevdgv.Text.Trim() != "" )
  1001. {
  1002. this.dgvData.CurrentRow.Cells["取件人"].Value = this.cmbtreevdgv.Text.Trim();
  1003. this.dgvData.CurrentRow.Cells["取件人"].Tag = this.cmbtreevdgv.Tag;
  1004. }
  1005. else
  1006. {
  1007. this.dgvData.CurrentRow.Cells["取件人"].Value = "";
  1008. this.dgvData.CurrentRow.Cells["取件人"].Tag = null;
  1009. }
  1010. this.dgvData.CurrentRow.Tag = "1";
  1011. }
  1012. this.cmbtreevdgv.Visible = false;
  1013. }
  1014. }
  1015. /// <summary>
  1016. /// 备注控件离开事件
  1017. /// </summary>
  1018. /// <param name="sender"></param>
  1019. /// <param name="e"></param>
  1020. void txtdgv_Leave( object sender, EventArgs e )
  1021. {
  1022. if ( this.txtdgv.Tag.ToString().Trim() == "BZ" )
  1023. {
  1024. this.dgvData.CurrentRow.Cells["预约说明"].Value = this.txtdgv.Text.Trim();
  1025. this.dgvData.CurrentRow.Tag = "1";
  1026. }
  1027. this.txtdgv.Visible = false;
  1028. }
  1029. /// <summary>
  1030. /// 列表列点击事件(右键)
  1031. /// </summary>
  1032. /// <param name="sender"></param>
  1033. /// <param name="e"></param>
  1034. void dgvData_CellMouseDown( object sender, DataGridViewCellMouseEventArgs e )
  1035. {
  1036. if ( e.Button == MouseButtons.Right )
  1037. {
  1038. this.mskdgv.Visible = false;
  1039. this.dtpcdgv.Visible = false;
  1040. this.cmbtreevdgv.Visible = false;
  1041. ToolStripMenuItem item = null;
  1042. if ( e.ColumnIndex == this.dgvData.Columns["取件日期"].Index )
  1043. {
  1044. //弹出操作菜单
  1045. item = new ToolStripMenuItem();
  1046. item.Text = "清空值";
  1047. item.Tag = "StrDate";
  1048. this.dgvData.conMenu.Items.Add( item );
  1049. item = new ToolStripMenuItem();
  1050. item.Text = "选择日期";
  1051. item.Tag = "StrDate";
  1052. this.dgvData.conMenu.Items.Add( item );
  1053. }
  1054. else if ( e.ColumnIndex == this.dgvData.Columns["取件时间"].Index )
  1055. {
  1056. //弹出操作菜单
  1057. item = new ToolStripMenuItem();
  1058. item.Text = "清空值";
  1059. item.Tag = "StrTime";
  1060. this.dgvData.conMenu.Items.Add( item );
  1061. item = new ToolStripMenuItem();
  1062. item.Text = "选择时间";
  1063. item.Tag = "StrTime";
  1064. this.dgvData.conMenu.Items.Add( item );
  1065. }
  1066. else if ( e.ColumnIndex == this.dgvData.Columns["取件人"].Index )
  1067. {
  1068. //弹出操作菜单
  1069. item = new ToolStripMenuItem();
  1070. item.Text = "清空值";
  1071. item.Tag = "STrCmbTreeV";
  1072. this.dgvData.conMenu.Items.Add( item );
  1073. item = new ToolStripMenuItem();
  1074. item.Text = "选择人员";
  1075. item.Tag = "STrCmbTreeV";
  1076. this.dgvData.conMenu.Items.Add( item );
  1077. }
  1078. }
  1079. }
  1080. /// <summary>
  1081. /// 获取预约门店ID
  1082. /// </summary>
  1083. /// <returns></returns>
  1084. List<string> GetSelectShopID()
  1085. {
  1086. List<string> shopIDlist = new List<string>();
  1087. foreach (DataGridViewRow dataGridView in this.dgvData.SelectedRows)
  1088. {
  1089. if (dataGridView.Cells["取件门店"].Tag != null)
  1090. {
  1091. string shopID = dataGridView.Cells["取件门店"].Tag.ToString();
  1092. if (!shopIDlist.Any(s => s.ToLower() == shopID.ToLower()))
  1093. {
  1094. shopIDlist.Add(shopID);
  1095. }
  1096. }
  1097. }
  1098. if (shopIDlist.Count > 1)
  1099. {
  1100. MessageBoxCustom.Show("不能同时预约不同门店的摄控时间");
  1101. }
  1102. return shopIDlist;
  1103. }
  1104. /// <summary>
  1105. /// 获取预约日期
  1106. /// </summary>
  1107. /// <returns></returns>
  1108. List<DateTime> GetDateTime()
  1109. {
  1110. List<DateTime> dateTimelist = new List<DateTime>();
  1111. foreach (DataGridViewRow dataGridView in this.dgvData.SelectedRows)
  1112. {
  1113. if (dataGridView.Cells["取件日期"].Value != null)
  1114. {
  1115. string dateTimeString = dataGridView.Cells["取件日期"].Value.ToString();
  1116. if (!String.IsNullOrWhiteSpace(dateTimeString))
  1117. {
  1118. if (!dateTimelist.Any(d => d.ToYYYY_MM_dd().ToLower() == dateTimeString.ToLower()))
  1119. {
  1120. dateTimelist.Add(Convert.ToDateTime(dateTimeString));
  1121. }
  1122. }
  1123. }
  1124. }
  1125. if (dateTimelist.Count > 1)
  1126. {
  1127. MessageBoxCustom.Show("不能同时预约不同日期的摄控时间");
  1128. }
  1129. return dateTimelist;
  1130. }
  1131. /// <summary>
  1132. /// 右键菜单选择项事件
  1133. /// </summary>
  1134. /// <param name="sender"></param>
  1135. /// <param name="e"></param>
  1136. void dgvData_DataGridViewConMenu_ItemClicked( object sender, ToolStripItemClickedEventArgs e )
  1137. {
  1138. ToolStripItem item = e.ClickedItem;
  1139. string strID = "";
  1140. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1141. {
  1142. strID += "'" + this.dgvData.SelectedRows[i].Cells["ID"].Value.ToString().Trim() + "',";
  1143. }
  1144. DataTable dt = orbll.GetView_Custom( "tb_ErpOrderProductList", StrWhere: "ID in (" + strID.TrimEnd( ',' ) + ")", ShowColumnName: "ID,OPlist_ReservationTakeName,OPlist_ReservationTakeTime,OPlist_ArrangeRemark" ).Tables[0];
  1145. dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
  1146. if ( item.Tag.ToString().Trim() == "StrDate" )
  1147. {
  1148. if ( item.Text.Trim() == "选择日期" )
  1149. {
  1150. LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetDateSuperSmallForm frm = new SuperSmallForm.GetDateSuperSmallForm();
  1151. frm.ShowDialog();
  1152. if ( frm.IsOK )
  1153. {
  1154. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1155. {
  1156. DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] );
  1157. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["OPlist_ReservationTakeTime"].ToString() ) ) && !IsUpdateAnPai )
  1158. {
  1159. return;
  1160. }
  1161. this.dgvData.SelectedRows[i].Cells["取件日期"].Value = frm.StrValue;
  1162. if (TimeTemplateKeyValues.ContainsKey(this.dgvData.SelectedRows[i].Index))
  1163. {
  1164. if (TimeTemplateKeyValues[this.dgvData.SelectedRows[i].Index].DayTemplate.CameraDateTime.JavaScriptTimeStampToDateTime().ToYYYY_MM_dd() != frm.StrValue.Trim())
  1165. {
  1166. this.dgvData.SelectedRows[i].Cells["取件时间"].Value = "";
  1167. this.TimeTemplateKeyValues.Remove(this.dgvData.SelectedRows[i].Index);
  1168. }
  1169. }
  1170. this.dgvData.SelectedRows[i].Tag = "1";
  1171. }
  1172. }
  1173. }
  1174. else
  1175. {
  1176. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1177. {
  1178. DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] );
  1179. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["OPlist_ReservationTakeTime"].ToString() ) ) && !IsUpdateAnPai )
  1180. {
  1181. return;
  1182. }
  1183. this.dgvData.SelectedRows[i].Cells["取件日期"].Value = "";
  1184. if (TimeTemplateKeyValues.ContainsKey(this.dgvData.SelectedRows[i].Index))
  1185. {
  1186. this.dgvData.SelectedRows[i].Cells["取件时间"].Value = "";
  1187. this.TimeTemplateKeyValues.Remove(this.dgvData.SelectedRows[i].Index);
  1188. }
  1189. this.dgvData.SelectedRows[i].Tag = "1";
  1190. }
  1191. }
  1192. }
  1193. else if ( item.Tag.ToString().Trim() == "StrTime" )
  1194. {
  1195. if ( item.Text.Trim() == "选择时间" )
  1196. {
  1197. /* LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetTimeSuperSmallForm frm = new SuperSmallForm.GetTimeSuperSmallForm();
  1198. frm.ShowDialog();
  1199. if ( frm.IsOK )
  1200. {
  1201. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1202. {
  1203. DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] );
  1204. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["OPlist_ReservationTakeTime"].ToString() ) ) && LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeTime"].ToString(), "HH:mm" ) != "00:00" && !IsUpdateAnPai )
  1205. {
  1206. return;
  1207. }
  1208. this.dgvData.SelectedRows[i].Cells["取件时间"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1";
  1209. }
  1210. }*/
  1211. DateTime dayDate = SDateTime.Now;
  1212. string shopID = "";
  1213. List<DateTime> dateTimes = GetDateTime();
  1214. List<string> selectShopIDs = GetSelectShopID();
  1215. if (dateTimes.Count > 0)
  1216. {
  1217. dayDate = dateTimes[0];
  1218. }
  1219. if (selectShopIDs.Count > 0)
  1220. {
  1221. shopID = selectShopIDs[0];
  1222. }
  1223. if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition)
  1224. {
  1225. if (selectShopIDs.Count <= 0)
  1226. {
  1227. MessageBoxCustom.Show("需要先选择要预约的门店");
  1228. return;
  1229. }
  1230. }
  1231. if (dateTimes.Count <= 0)
  1232. {
  1233. MessageBoxCustom.Show("需要先选择取件日期");
  1234. return;
  1235. }
  1236. Model.CameraTimeTemplate cameraTime =PhotographedReservationSmallForm.GetCameraTime(dayDate, shopID, Model.CameraType.取件客人, this.GetCameraOrderType());
  1237. if (cameraTime != null)
  1238. {
  1239. for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
  1240. {
  1241. DataRow dtRow = dt.Rows.Find(dt.Rows[0]["ID"]);
  1242. if (!string.IsNullOrEmpty(LYFZ.Command.Command_Validate.DateTimeToString(dtRow["OPlist_ReservationTakeTime"].ToString())) && LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[0]["OPlist_ReservationTakeTime"].ToString(), "HH:mm") != "00:00" && !IsUpdateAnPai)
  1243. {
  1244. return;
  1245. }
  1246. if (TimeTemplateKeyValues.ContainsKey(this.dgvData.SelectedRows[i].Index))
  1247. {
  1248. this.TimeTemplateKeyValues.Remove(this.dgvData.SelectedRows[i].Index);
  1249. }
  1250. this.TimeTemplateKeyValues.Add(this.dgvData.SelectedRows[i].Index, cameraTime);
  1251. this.dgvData.SelectedRows[i].Cells["取件时间"].Value = cameraTime.CameraTime;
  1252. this.dgvData.SelectedRows[i].Tag = "1";
  1253. }
  1254. }
  1255. }
  1256. else
  1257. {
  1258. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1259. {
  1260. DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] );
  1261. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["OPlist_ReservationTakeTime"].ToString() ) ) && LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["OPlist_ReservationTakeTime"].ToString(), "HH:mm" ) != "00:00" && !IsUpdateAnPai )
  1262. {
  1263. return;
  1264. }
  1265. this.dgvData.SelectedRows[i].Cells["取件时间"].Value = "";
  1266. if (TimeTemplateKeyValues.ContainsKey(this.dgvData.SelectedRows[i].Index))
  1267. {
  1268. this.TimeTemplateKeyValues.Remove(this.dgvData.SelectedRows[i].Index);
  1269. }
  1270. this.dgvData.SelectedRows[i].Tag = "1";
  1271. }
  1272. }
  1273. }
  1274. else if ( item.Tag.ToString().Trim() == "STrCmbTreeV" )
  1275. {
  1276. if ( item.Text.Trim() == "选择人员" )
  1277. {
  1278. LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.SelectWorkPersonSuperSmallForm frm = new SuperSmallForm.SelectWorkPersonSuperSmallForm();
  1279. frm.StrTime = this.dgvData.CurrentRow.Cells["取件日期"].Value.ToString().Trim();
  1280. frm.WorkPersonType = LYFZ.EnumPublic.EnumWorkPersonType.取件师;
  1281. frm.ShowDialog();
  1282. if ( frm.IsSaveed )
  1283. {
  1284. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1285. {
  1286. DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] );
  1287. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["OPlist_ReservationTakeName"].ToString() ) ) && !IsUpdateAnPai )
  1288. {
  1289. return;
  1290. }
  1291. this.dgvData.SelectedRows[i].Cells["取件人"].Value = frm.StrPersonName;
  1292. this.dgvData.SelectedRows[i].Cells["取件人"].Tag = frm.StrPersonNumber;
  1293. this.dgvData.SelectedRows[i].Tag = "1";
  1294. }
  1295. this.dgvData.CurrentRow.Tag = "1";
  1296. }
  1297. }
  1298. else
  1299. {
  1300. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  1301. {
  1302. DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] );
  1303. if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["OPlist_ReservationTakeName"].ToString() ) ) && !IsUpdateAnPai )
  1304. {
  1305. return;
  1306. }
  1307. this.dgvData.SelectedRows[i].Cells["取件人"].Value = "";
  1308. this.dgvData.SelectedRows[i].Cells["取件人"].Tag = null;
  1309. this.dgvData.SelectedRows[i].Tag = "1";
  1310. }
  1311. }
  1312. }
  1313. }
  1314. }
  1315. }