123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using LYFZ.ComponentLibrary;
- using LYFZ.Model;
- namespace LYFZ.Software.MainBusiness.NewCameraControlBook
- {
- public class AddTimeTemplate : LYFZ.Software.NewCameraControlBook.AddTimeTemplate
- {
- public AddTimeTemplate()
- {
- this.Shown += AddTimeTemplate_Shown;
- this.btnSave.Click += BtnSave_Click;
- this.btnColse.Click += BtnColse_Click;
- this.txtTimeTemplateValue.BaseText.TextChanged += BaseText_TextChanged;
- this.SizeChanged += AddTimeTemplate_SizeChanged;
- this.lkFormatTime1.Click += LkFormatTime1_Click;
- this.lkFormatTime2.Click += LkFormatTime2_Click;
- }
- private void LkFormatTime1_Click(object sender, EventArgs e)
- {
- string timeString = BLL.CameraTemplateHandle.FormatTimeStirng(this.txtTimeTemplateValue.Text.Trim());
- this.txtTimeTemplateValue.Text = timeString.Replace(",", System.Environment.NewLine);
- this.BaseText_TextChanged(null,null);
- if (sender!=null&&!this.VerificationTimeString(timeString))
- {
- MessageBoxCustom.Show(String.Format("格式化完成,但是检测到输入的时间格式不正确"));
- }
- }
- private void LkFormatTime2_Click(object sender, EventArgs e)
- {
- this.txtTimeTemplateValue.Text = BLL.CameraTemplateHandle.FormatTimeStirng(this.txtTimeTemplateValue.Text.Trim());
- this.BaseText_TextChanged(null, null);
- if (sender != null && !this.VerificationTimeString(this.txtTimeTemplateValue.Text.Trim()))
- {
- MessageBoxCustom.Show(String.Format("格式化完成,但是检测到输入的时间格式不正确"));
- }
- }
- private void AddTimeTemplate_SizeChanged(object sender, EventArgs e)
- {
- if (this.WindowState == System.Windows.Forms.FormWindowState.Maximized)
- {
- this.LkFormatTime1_Click(null,null);
- }
- else {
- this.LkFormatTime2_Click(null, null);
- }
-
- }
- private void BaseText_TextChanged(object sender, EventArgs e)
- {
- string timeString = BLL.CameraTemplateHandle.FormatTimeStirng(this.txtTimeTemplateValue.Text.Trim());
- if (!String.IsNullOrWhiteSpace(timeString))
- {
- string[] timeList = BLL.CameraTemplateHandle.TimeStirngToSplit(timeString);
- this.skinLabel1.Text = String.Format("共计:{0} 个档期", timeList.Length);
- }
- }
- private void BtnColse_Click(object sender, EventArgs e)
- {
- this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- }
- private void BtnSave_Click(object sender, EventArgs e)
- {
- List<CameraTimeTemplate> tempList = cameraTemplate.TimeTemplateData.TimeTemplateDataList.FindAll(t => t.ReservationTime.IsEnable == 0 || !String.IsNullOrWhiteSpace(t.ReservationTime.OrderNumber));
-
- string timeString = BLL.CameraTemplateHandle.FormatTimeStirng(this.txtTimeTemplateValue.Text.Trim());
- if (this.VerificationTimeString(timeString))
- {
- this.txtTimeTemplateValue.Text = timeString;
- string[] timeList = BLL.CameraTemplateHandle.TimeStirngToSplit(timeString);
- if (timeList.Length > 100)
- {
- MessageBoxCustom.Show("摄控本模板档期数量最大不能超过100个");
- return;
- }
-
- cameraTemplate.TimeTemplateData.TimeTemplateDataList.Clear();
-
- foreach (string timeValue in timeList)
- {
- if (tempList.Any(t => t.CameraTime == timeValue))
- {
- CameraTimeTemplate cameraTime = tempList.Find(t => t.CameraTime == timeValue);
- cameraTemplate.TimeTemplateData.TimeTemplateDataList.Add(cameraTime);
- tempList.Remove(cameraTime);
- }
- else
- {
- cameraTemplate.TimeTemplateData.TimeTemplateDataList.Add(new CameraTimeTemplate { ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId(), CameraTime = timeValue ,DayTemplate= cameraTemplate });
- }
- }
- cameraTemplate.TimeTemplateData.TimeTemplateDataList.AddRange(tempList);
- cameraTemplate.TimeTemplateData.TimeTemplateDataList = cameraTemplate.TimeTemplateData.TimeTemplateDataList.OrderBy(t => t.CameraTime).ToList();
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- }
- else {
- if (String.IsNullOrWhiteSpace(timeString))
- {
- cameraTemplate.TimeTemplateData.TimeTemplateDataList.Clear();
- cameraTemplate.TimeTemplateData.TimeTemplateDataList.AddRange(tempList);
- cameraTemplate.TimeTemplateData.TimeTemplateDataList = cameraTemplate.TimeTemplateData.TimeTemplateDataList.OrderBy(t => t.CameraTime).ToList();
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- }
- else
- {
- MessageBoxCustom.Show(String.Format("输入的时间格式不正确"));
- }
- }
- }
-
- private void AddTimeTemplate_Shown(object sender, EventArgs e)
- {
- CameraOrderType cameraOrderType = (CameraOrderType)cameraTemplate.OrderType;
- CameraType cameraType= (CameraType)cameraTemplate.CameraType;
- this.lbTibsInfo.Text= String.Format("{0}:{1} 日期:{2} 说明:已预约和被禁用的档期不可修改", cameraType.ToString(), cameraOrderType.ToString(), currentDataRow.DataColumnList[0].Text.Replace("\r\n"," "));
- this.txtTimeTemplateValue.Text = cameraTemplate.TimeTemplateData.ToTimeValueString();
- }
- bool VerificationTimeString(string timeString)
- {
- return BLL.CameraTemplateHandle.VerificationTimeString(timeString);
- }
- Model.CameraControlTemplate cameraTemplate = new Model.CameraControlTemplate();
- ComponentLibrary.PDataRow currentDataRow;
- /// <summary>
- /// 当前行
- /// </summary>
- public PDataRow CurrentDataRow { get => currentDataRow; set => currentDataRow = value; }
- /// <summary>
- /// 摄控数据
- /// </summary>
- public CameraControlTemplate CameraTemplate { get => cameraTemplate; set => cameraTemplate = value; }
- }
- }
|