123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897 |
- using LYFZ.BLL;
- using LYFZ.ComponentLibrary;
- using LYFZ.Model;
- 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;
- namespace LYFZ.Software.MainBusiness.NewCameraControlBook
- {
- public class SetCameraTemplate:LYFZ.Software.NewCameraControlBook.SetCameraTemplate
- {
- PanelToDataTableView PanelDataView = null;
- LYFZ.Software.MainBusiness.EnumPermissions.BusinessType CurrentBusinessType = EnumPermissions.BusinessType.旗舰版;
- public SetCameraTemplate()
- {
- CurrentBusinessType = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType();
- if (CurrentBusinessType == EnumPermissions.BusinessType.婚纱版)
- {
- this.rdoHospitalClient.Hide();
- }
- else {
- this.rdoHospitalClient.Show();
- }
- this.dateTimePickerStar.Value = SDateTime.Now;
- PanelDataView = new PanelToDataTableView(this.plTbleContainer);
- PanelDataView.EventCell_Click += PanelDataView_EventCell_Click;
- PanelDataView.EventCell_DoubleClick += PanelDataView_EventCell_DoubleClick;
- PanelDataView.EventCell_MouseEnter += PanelDataView_EventCell_MouseEnter;
- PanelDataView.EventCellThumbtack_MouseEnter += PanelDataView_EventCellThumbtack_MouseEnter;
- PanelDataView.EventCellThumbtack_DoubleClick += PanelDataView_EventCellThumbtack_DoubleClick;
- this.cmenuCameraBook.ItemClicked += CmenuCameraBook_ItemClicked;
- this.Shown += SetCameraTemplate_Shown;
- this.Load += SetCameraTemplate_Load;
- this.lkBeforeDay.Click += BtnBeforeDay_Click;
- this.lkAfterDay.Click += BtnAfterDay_Click;
- this.lkNearlyOneWeek.Click += BtnNearlyOneWeek_Click;
- this.dateTimePickerStar.ValueChanged += DateTimePickerStar_ValueChanged;
- this.btnExportTemplate.Click += BtnExportTemplate_Click;
- this.btnImportTemplate.Click += BtnImportTemplate_Click;
- this.btnDellTle.Click += BtnDellTle_Click;
- this.SizeChanged += SetCameraTemplate_SizeChanged;
- this.RegisteredRadioButtonEvent();
- this.btnDelError.Click += BtnDelError_Click;
- }
- private void BtnDelError_Click(object sender, EventArgs e)
- {
- if (LYFZ.DAL.CameraControlTemplate.DelErrorTemplate())
- {
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- MessageBoxCustom.Show("清除成功");
- }
- else {
- MessageBoxCustom.Show("清除失败");
- }
- }
- private bool whetherUpdate = false;
- private void BtnDellTle_Click(object sender, EventArgs e)
- {
-
- if (MessageBoxCustom.Show("执行清空档期后将不能恢复,是否要继续清空当前档期设置?") != DialogResult.OK)
- {
- return;
- }
- List<Model.CameraControlTemplate> delList = new List<Model.CameraControlTemplate>();
- bool isNoDell = false;
- foreach (PDataRow row in this.PanelDataView.DataRowList)
- {
- Model.CameraControlTemplate cameraTemplate = (Model.CameraControlTemplate)row.Tag;
- if (cameraTemplate.TimeTemplateData.TimeTemplateDataList.Any(t => t.ReservationTime.IsEnable == 0 || !String.IsNullOrWhiteSpace(t.ReservationTime.OrderNumber)))
- {
-
- isNoDell = true;
- }
- else {
- delList.Add(cameraTemplate);
- }
- }
- if (delList.Count>0)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- List<long> longIds = new List<long>();
- foreach (Model.CameraControlTemplate row in delList)
- {
- longIds.Add(row.ID);
- }
- cameraTemplateBll.DeleteList(String.Join(",", longIds));
- });
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- this.whetherUpdate = true;
- }
- if(isNoDell)
- {
- MessageBoxCustom.Show("为了避免误操作\r\n档期中有被安排过客人或有被设置为禁用的档期时不可清空");
- }
- }
- /// <summary>
- /// 导入模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnImportTemplate_Click(object sender, EventArgs e)
- {
- OpenFileDialog ImportRoleDlg = new OpenFileDialog();
- ImportRoleDlg.Filter = "档期模板|*.tle";
- if (ImportRoleDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- try
- {
- CameraType cameraType = SetCameraTemplate.GetCameraType(this.flowLayoutPanel3.Controls);
- string ImportRoleFileName = ImportRoleDlg.FileName;
- if (System.IO.File.Exists(ImportRoleFileName))
- {
- dynamic ImportDataList =Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(ImportRoleFileName, Encoding.UTF8));
- if (Convert.ToInt32(ImportDataList.TleCameraType)!=(int)cameraType)
- {
- MessageBoxCustom.Show("选择的档期模板不是当前类型的模板数据,请重新选择!");
- return;
- }
- bool isSaveOk = true;
-
- List<Model.CameraControlTemplate> templateList = new List<Model.CameraControlTemplate>();
- if (ImportDataList.DataList.Count > 0)
- {
- foreach (dynamic iData in ImportDataList.DataList)
- {
- try
- {
- string WeekName = iData.WeekName;
- List<ComponentLibrary.PDataRow> dataRowList = this.PanelDataView.DataRowList.FindAll(r => r.DataColumnList[0].Tag.ToString() == WeekName);
- if (iData.ValueList.Count > 0)
- {
- foreach (dynamic vData in iData.ValueList)
- {
- int orderType = Convert.ToInt32(vData.orderType);
- PDataRow dataRow = dataRowList.Find(r => ((Model.CameraControlTemplate)r.Tag).OrderType == orderType);
- if (dataRow != null)
- {
- Model.CameraControlTemplate template = (Model.CameraControlTemplate)dataRow.Tag;
- List<CameraTimeTemplate> tempList = template.TimeTemplateData.TimeTemplateDataList.FindAll(t => t.ReservationTime.IsEnable == 0 || !String.IsNullOrWhiteSpace(t.ReservationTime.OrderNumber));
- template.TimeTemplateData.TimeTemplateDataList.Clear();
- string[] values = vData.values.ToString().Split(',');
- foreach (string timeValue in values)
- {
- if (!String.IsNullOrWhiteSpace(timeValue))
- {
- if (tempList.Any(t => t.CameraTime == timeValue))
- {
- CameraTimeTemplate cameraTime = tempList.Find(t => t.CameraTime == timeValue);
- template.TimeTemplateData.TimeTemplateDataList.Add(cameraTime);
- tempList.Remove(cameraTime);
- }
- else
- {
- template.TimeTemplateData.TimeTemplateDataList.Add(new CameraTimeTemplate { ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId(), CameraTime = timeValue, DayTemplate = template });
- }
- }
- }
- template.TimeTemplateData.TimeTemplateDataList.AddRange(tempList);
- template.TimeTemplateData.TimeTemplateDataList = template.TimeTemplateData.TimeTemplateDataList.OrderBy(t => t.CameraTime).ToList();
- if (template.ID > 0)
- {
- template.UpdateDateTime = SDateTime.Now.ToJavaScriptTimeStamp();
- template.UpdatePeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- }
- else
- {
- template.CreateDateTime = SDateTime.Now.ToJavaScriptTimeStamp();
- template.CreatePeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- template.UpdateDateTime = SDateTime.Now.ToJavaScriptTimeStamp();
- template.UpdatePeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- }
- if (template.TimeTemplateData.TimeTemplateDataList.Count > 0)
- {
- templateList.Add(template);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- isSaveOk = false;
- MessageBoxCustom.Show("档期模板导入失败:" + ex.Message);
- break;
- }
- }
- }
- if (isSaveOk)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- backgroundWorker.ReportProgress(0, "正在导入档期模板,请稍等...");
- foreach (Model.CameraControlTemplate template in templateList)
- {
- backgroundWorker.ReportProgress(0, String.Format("正在导入 {0}-{1} 档期模板,请稍等..."
- , template.CameraDateTime.JavaScriptTimeStampToDateTime().ToYYYY_MM_dd(), ((CameraOrderType)template.OrderType).ToString()));
- if (template.ID > 0)
- {
- if (!cameraTemplateBll.Update(template))
- {
- isSaveOk = false;
- break;
- }
- }
- else
- {
- template.ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId();
- if (cameraTemplateBll.Add(template))
- {
- this.CameraControlTemplateList.Add(template);
- }
- else
- {
- isSaveOk = false;
- break;
- }
- }
- }
- });
- }
- if (isSaveOk)
- {
- // LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog("", LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- MessageBoxCustom.Show("档期模板导入成功");
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- this.whetherUpdate = true;
- }
- else
- {
- MessageBoxCustom.Show("档期模板导入失败,请重启软件后重试");
- }
- }
- else
- {
- MessageBoxCustom.Show("选择的档期模板文件不存在");
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show("档期模板导入失败:" + ex.Message);
- }
- }
- }
- /// <summary>
- /// 导出模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnExportTemplate_Click(object sender, EventArgs e)
- {
- SaveFileDialog ExportRoleDlg = new SaveFileDialog();
- ExportRoleDlg.Filter = "档期模板|*.tle";
- CameraType cameraType = SetCameraTemplate.GetCameraType(this.flowLayoutPanel3.Controls);
- ExportRoleDlg.FileName =String.Format("{0}_{1}_档期模板_{2}" , GetCurrentStoreInfo().DividedShop_Name, cameraType.ToString(), SDateTime.Now.ToString("yyyy-MM-dd"));
- if (ExportRoleDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- try
- {
- string ImportRoleFileName = LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(System.IO.Path.GetDirectoryName(ExportRoleDlg.FileName))
- + System.IO.Path.GetFileNameWithoutExtension(ExportRoleDlg.FileName) + ".tle";
-
- List<object> tleDataList = new List<object>();
- for (int i = 0; i < weekNames.Length; i++)
- {
- List< ComponentLibrary.PDataRow > rowList= this.PanelDataView.DataRowList.FindAll(r=>r.DataColumnList[0].Tag.ToString()== weekNames[i]);
- List<object> valueList = new List<object>();
- foreach (PDataRow row in rowList)
- {
- Model.CameraControlTemplate cameraTemplate = (Model.CameraControlTemplate)row.Tag;
- valueList.Add(new {
- orderType = cameraTemplate.OrderType
- ,values= cameraTemplate.TimeTemplateData.ToTimeValueString()
- });
- }
- tleDataList.Add(new
- {
- WeekName = weekNames[i]
- ,
- ValueList = valueList
- });
- }
- dynamic tleData = new {
- TleCameraType= cameraType
- ,
- DataList= tleDataList
- };
- string ExportRoleData = Newtonsoft.Json.JsonConvert.SerializeObject(tleData);
- System.IO.File.WriteAllText(ImportRoleFileName, ExportRoleData.Trim('|'), Encoding.UTF8);
- MessageBoxCustom.Show("档期模板数据导出成功");
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show("档期模板数据导出失败:" + ex.Message);
- }
- }
- }
- void RegisteredRadioButtonEvent()
- {
- foreach (Control con in this.flowLayoutPanel3.Controls)
- {
- if (con.GetType() == typeof(LYFZ.ComponentLibrary.RadioButtonEx))
- {
- LYFZ.ComponentLibrary.RadioButtonEx rdo = (LYFZ.ComponentLibrary.RadioButtonEx)con;
- rdo.Click += Rdo_Click;
- }
- }
- }
- private void Rdo_Click(object sender, EventArgs e)
- {
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- }
- private void SetCameraTemplate_SizeChanged(object sender, EventArgs e)
- {
- foreach (PDataColumn column in this.PanelDataView.HeadColumnRow.DataColumnList)
- {
- column.Width = GetTitleDataColumnWidth(column.Text);
- }
- this.PanelDataView.RefreshTableView();
- }
- LYFZ.BLL.CameraControlTemplate cameraTemplateBll = new BLL.CameraControlTemplate();
- LYFZ.DAL.CameraControlTemplate cameraTemplateDal = new DAL.CameraControlTemplate();
- LYFZ.BLL.ThumbtackRecord thumbtackBll = new BLL.ThumbtackRecord();
- private void SetCameraTemplate_Load(object sender, EventArgs e)
- {
- if (LYFZ.BLL.BLL_ErpUser.IsAdministrator())
- {
- this.btnDelError.Show();
- }
- else {
- this.btnDelError.Hide();
- }
- }
- private void SetCameraTemplate_Shown(object sender, EventArgs e)
- {
- this.lbShopName.Text = this.GetCurrentStoreInfo().DividedShop_Name;
- this.LoadCameraControlTemplate();
- BindPanelDataView();
-
- }
- List<LYFZ.Model.CameraControlTemplate> CameraControlTemplateList = new List<Model.CameraControlTemplate>();
- List<LYFZ.Model.ThumbtackRecord> thumbtackRecordList = new List<Model.ThumbtackRecord>();
- /// <summary>
- /// 加载模板数据
- /// </summary>
- void LoadCameraControlTemplate()
- {
- CameraType cameraType = SetCameraTemplate.GetCameraType(this.flowLayoutPanel3.Controls);
- LoadCameraControlTemplate(DateStart, DateEnd,(int)cameraType, GetCurrentStoreInfo().DividedShop);
- }
- DateTime DateStart
- {
- get {
- DateTime selectDate = this.dateTimePickerStar.Value;
- int dayOfWeekIndex = GetDayOfWeekIndex(selectDate.DayOfWeek);
- return selectDate.AddDays(-(dayOfWeekIndex - (0 + 1)));
- }
- }
- DateTime DateEnd
- {
- get
- {
- DateTime selectDate = this.dateTimePickerStar.Value;
- int dayOfWeekIndex = GetDayOfWeekIndex(selectDate.DayOfWeek);
- return selectDate.AddDays(-(dayOfWeekIndex - (6 + 1)));
- }
- }
- public bool WhetherUpdate { get => whetherUpdate; set => whetherUpdate = value; }
- /// <summary>
- /// 加载模板数据
- /// </summary>
- /// <param name="dateStart"></param>
- /// <param name="dateEnd"></param>
- void LoadCameraControlTemplate(DateTime dateStart, DateTime dateEnd, int cameraType, string shopID)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- this.CameraControlTemplateList = cameraTemplateBll.GetCameraControlTemplateList(dateStart, dateEnd.ToDayDateMaxTime(), cameraType, shopID);
- // this.thumbtackRecordList = thumbtackBll.GetThumbtackRecordList(dateStart, dateEnd);
- });
-
- }
- private void PanelDataView_EventCellThumbtack_MouseEnter(Panel viewPanel, DataEventArgs e)
- {
- this.tpsInfo.ToolTipTitle = "图钉内容预览";
- this.tpsInfo.Show(String.Format("{0}", e.CurrentThumbtack.ThumbtackText), this.PanelDataView, new Point(e.MousePoint.X + 10, e.MousePoint.Y), 5000);
- }
- private void PanelDataView_EventCellThumbtack_DoubleClick(Panel viewPanel, DataEventArgs e)
- {
- MessageBoxCustom.Show(e.CurrentThumbtack.ThumbtackText);
- }
-
- private void PanelDataView_EventCell_MouseEnter(Panel viewPanel, DataEventArgs e)
- {
- }
- private void PanelDataView_EventCell_DoubleClick(Panel viewPanel, DataEventArgs e)
- {
- if (e.CurrentCell.CellIndex > 0 && !e.IsHeadRow)
- {
- if (e.CrrrentRow.Tag != null)
- {
- Model.CameraControlTemplate template= (Model.CameraControlTemplate)e.CrrrentRow.Tag;
-
- AddTimeTemplate addTime = new AddTimeTemplate();
- addTime.CurrentDataRow = e.CrrrentRow;
- addTime.CameraTemplate = template;
- List<CameraTimeTemplate> OldTimeTemplateDataList = new List<CameraTimeTemplate>(template.TimeTemplateData.TimeTemplateDataList);
- if (addTime.ShowDialog() == DialogResult.OK)
- {
- bool isSave = true;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- try
- {
- if (template.ID <= 0)
- {
- template.ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId();
- template.CreateDateTime = SDateTime.Now.ToJavaScriptTimeStamp();
- template.CreatePeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- template.UpdateDateTime = SDateTime.Now.ToJavaScriptTimeStamp();
- template.UpdatePeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (template.TimeTemplateData.TimeTemplateDataList.Count > 0)
- {
- if (cameraTemplateBll.Add(template))
- {
- this.CameraControlTemplateList.Add(template);
- isSave = true;
- }
- else
- {
- template.ID = 0;
- isSave = false;
- }
- }
- }
- else
- {
- if (template.TimeTemplateData.TimeTemplateDataList.Count > 0)
- {
- template.UpdateDateTime = SDateTime.Now.ToJavaScriptTimeStamp();
- template.UpdatePeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- isSave = cameraTemplateBll.Update(template);
- }
- else
- {
- isSave = cameraTemplateBll.Delete(template);
- }
- }
- }
- catch (Exception ex){
- MessageBoxCustom.Show("保存模板失败:"+ ex.Message);
- }
- });
- if (isSave)
- {
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- this.whetherUpdate = true;
- }
- else {
- template.TimeTemplateData.TimeTemplateDataList.Clear();
- template.TimeTemplateData.TimeTemplateDataList.AddRange(OldTimeTemplateDataList);
- MessageBoxCustom.Show("模板数据保存失败,请重新启动软件后重试");
- }
- }
- }
- else {
- MessageBoxCustom.Show("模板数据不正确");
- }
- }
- }
- private void PanelDataView_EventCell_Click(Panel viewPanel, DataEventArgs e)
- {
- this.HideTpsInfo();
- /* if (e.Button == MouseButtons.Right)
- {
- if (!e.IsHeadRow)
- {
- if (e.CurrentCell.CellIndex > 2)
- {
- this.cmenuCameraBook.Tag = e.CrrrentRow;
- this.cmenuCameraBook.Show(this.PanelDataView, e.MousePoint);
- }
- }
- }*/
- }
- /// <summary>
- /// 单击右键菜单时
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void CmenuCameraBook_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- /* PDataRow cRow = (PDataRow)this.cmenuCameraBook.Tag;
- Model.CameraControlTemplate template = (Model.CameraControlTemplate)cRow.Tag;
- //MessageBoxCustom.Show(String.Join(",", template.TimeTemplateData.TimeTemplateDataList));
- switch (e.ClickedItem.Text)
- {
- case "编辑档期":
- this.PanelDataView_EventCell_DoubleClick(this.PanelDataView, new DataEventArgs {
- CrrrentRow = cRow
- , CurrentCell = cRow.DataColumnList[3]
- });
- break;
- case "清除档期":
- if (template.TimeTemplateData.TimeTemplateDataList.Any(t => t.ReservationTime.IsEnable == 0 || !String.IsNullOrWhiteSpace(t.ReservationTime.OrderNumber)))
- {
- MessageBoxCustom.Show("为了避免误操作\r\n档期中已被预约或被设置为禁用的档期模板不可清除档期");
- return;
- }
- break;
- }*/
-
-
- }
-
- void HideTpsInfo()
- {
- this.tpsInfo.Hide(this.PanelDataView);
- }
- public static int GetDayOfWeekIndex(DayOfWeek dayOfWeek)
- {
- int weekIndex = (int)dayOfWeek;
- if (weekIndex == 0)
- {
- weekIndex = 7;
- }
- return weekIndex;
- }
- string[] titleNames = new string[4] { "设置日期", "订单类别", "档期数", "档期时间" };
- string[] weekNames = new string[7] { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };
-
- /// <summary>
- /// 绑定数据
- /// </summary>
- void BindPanelDataView()
- {
- this.PanelDataView.DataRowList.Clear();
- PanelDataView.HeadColumnRow.DataColumnList.Clear();
- PanelDataView.HeadColumnRow.Height = 32;
- for (int i = 0; i < titleNames.Length; i++)
- {
- PanelDataView.HeadColumnRow.DataColumnList.Add(GetNewTitleDataColumn(titleNames[i]));
- }
- CameraType cameraType = SetCameraTemplate.GetCameraType(this.flowLayoutPanel3.Controls);
- List<CameraOrderType> cameraOrderTypeList =SetCameraTemplate.GetCameraOrderTypeList(cameraType, GetCurrentStoreBusinessType());
- DateTime selectDate = this.dateTimePickerStar.Value;
- int dayOfWeekIndex = GetDayOfWeekIndex(selectDate.DayOfWeek);
- for (int i = 0; i < weekNames.Length; i++)
- {
- this.AddCameraDate(weekNames[i], selectDate.AddDays(-(dayOfWeekIndex- (i+1))), cameraOrderTypeList, cameraType);
- }
-
- PanelDataView.RefreshTableView();
- }
-
- public static CameraType GetCameraType(Control.ControlCollection controls)
- {
- CameraType cameraType = CameraType.拍照客人;
- foreach (Control con in controls)
- {
- if (con.GetType() == typeof(LYFZ.ComponentLibrary.RadioButtonEx))
- {
- LYFZ.ComponentLibrary.RadioButtonEx rdo = (LYFZ.ComponentLibrary.RadioButtonEx)con;
- if (rdo.Checked)
- {
- cameraType = (CameraType)Enum.Parse(typeof(CameraType), rdo.Text);
- break;
- }
- }
- }
- return cameraType;
- }
- public static List<CameraOrderType> GetCameraOrderTypeList(CameraType cameraType, EnumPermissions.BusinessType businessType)
- {
- List<CameraOrderType> cameraOrderTypes = new List<CameraOrderType>();
- switch (cameraType)
- {
- case CameraType.拍照客人:
- case CameraType.选片客人:
- case CameraType.看版客人:
- case CameraType.取件客人:
- case CameraType.选衣客人:
- case CameraType.服务客人:
- if (businessType != EnumPermissions.BusinessType.儿童版)
- {
- cameraOrderTypes.Add(CameraOrderType.婚纱订单);
- }
- if (businessType != EnumPermissions.BusinessType.婚纱版)
- {
- cameraOrderTypes.Add(CameraOrderType.儿童订单);
- }
- cameraOrderTypes.Add(CameraOrderType.写真订单);
- break;
- case CameraType.爱婴上门:
- cameraOrderTypes.Add(CameraOrderType.爱婴跟踪);
- break;
- }
- if (cameraType == CameraType.选衣客人)
- {
- cameraOrderTypes.Add(CameraOrderType.礼服租售);
- if (businessType != EnumPermissions.BusinessType.儿童版)
- {
- cameraOrderTypes.Add(CameraOrderType.婚庆订单);
- }
- }
- if (cameraType == CameraType.取件客人||cameraType== CameraType.服务客人)
- {
- cameraOrderTypes.Add(CameraOrderType.服务订单);
- if (businessType != EnumPermissions.BusinessType.儿童版)
- {
- cameraOrderTypes.Add(CameraOrderType.婚庆订单);
- }
- }
- return cameraOrderTypes;
- }
- void AddCameraDate(string weekName, DateTime dayDate, List<CameraOrderType> cameraOrderTypeList, CameraType cameraType)
- {
- for (int i = 0; i < cameraOrderTypeList.Count; i++)
- {
- int crossRowCount = 1;
- if (i == 0)
- {
- crossRowCount = cameraOrderTypeList.Count;
- }
- ComponentLibrary.PDataRow row = GetNewDataRow(weekName, dayDate, crossRowCount, cameraOrderTypeList[i], cameraType);
- if (cameraOrderTypeList.Count == 1)
- {
- row.Height = 64;
- }
- PanelDataView.DataRowList.Add(row);
- }
- }
- ComponentLibrary.PDataRow GetNewDataRow(string weekName, DateTime dayDate, int crossRowCount, CameraOrderType cameraOrderType, CameraType cameraType)
- {
- ComponentLibrary.PDataRow row = new PDataRow();
- string LunarCalendarDayTime = Command.Command_CalendarTurnLunar.GetChineseDateTimeToNoYear(dayDate);
- Model.CameraControlTemplate cameraTemplate = this.GetCameraControlTemplate(dayDate, cameraOrderType, cameraType);
- ComponentLibrary.PDataColumn cell0 = new ComponentLibrary.PDataColumn
- {
- Text = String.Format("{0}\r\n{1}\r\n{2}", weekName, dayDate.ToString("yyyy-MM-dd"), LunarCalendarDayTime)
- ,
- CrossRow = crossRowCount
- , DateTimeTag = dayDate
- ,Tag= weekName
- };
- ComponentLibrary.PDataColumn cell1 = new ComponentLibrary.PDataColumn
- {
- Text = String.Format("{0}", cameraOrderType.ToString())
- ,
- Tag = (int)cameraOrderType
- };
- ComponentLibrary.PDataColumn cell2 = new ComponentLibrary.PDataColumn
- {
- Text = String.Format("{0}", cameraTemplate.TimeTemplateData.TimeTemplateDataList.Count)
- };
- ComponentLibrary.PDataColumn cell3 = new ComponentLibrary.PDataColumn
- {
- Text = String.Format("{0}", cameraTemplate.TimeTemplateData.ToTimeTextString())
- ,TextAlignment= StringAlignment.Near
- };
- row.DataColumnList.AddRange(new ComponentLibrary.PDataColumn[] { cell0, cell1, cell2, cell3 });
- row.Tag = cameraTemplate;
- return row;
- }
- Model.CameraControlTemplate GetCameraControlTemplate(DateTime date, CameraOrderType cameraOrderType, CameraType cameraType)
- {
- Model.CameraControlTemplate cameraTemplate= this.CameraControlTemplateList.Find(t=>t.CameraDateTime==date.ToYYYYMMddDate().ToJavaScriptTimeStamp()&&t.CameraType== (int)cameraType && t.OrderType==(int)cameraOrderType);
- if (cameraTemplate == null)
- {
- cameraTemplate = new Model.CameraControlTemplate {
-
- CameraType= (int)cameraType
- ,OrderType= (int)cameraOrderType
- ,CameraDateTime=date.ToYYYYMMddDate().ToJavaScriptTimeStamp()
- ,
- ShopID=GetCurrentStoreInfo().DividedShop
- };
- }
- return cameraTemplate;
- }
- ComponentLibrary.PDataColumn GetNewTitleDataColumn(string titleName)
- {
- ComponentLibrary.PDataColumn cell = new ComponentLibrary.PDataColumn
- {
- Text = String.Format("{0}", titleName)
- ,
- Width = GetTitleDataColumnWidth(titleName)
- };
- if (titleName.Trim() == titleNames[3])
- {
- cell.TextAlignment = StringAlignment.Near;
- }
- return cell;
- }
- int GetTitleDataColumnWidth(string titleName)
- {
- int cell_width = 180;
- if (titleName.Trim() == titleNames[0])
- {
- cell_width = 180;
- }
- else if (titleName.Trim() == titleNames[1])
- {
- cell_width = 100;
- }
- else if (titleName.Trim() == titleNames[2])
- {
- cell_width = 80;
- }
- else if (titleName.Trim() == titleNames[3])
- {
- cell_width = this.Width - 400;
- if (cell_width < 480)
- {
- cell_width = 480;
- }
- }
- return cell_width;
- }
- #region 摄控详情时间控制
- bool isNowWeek = false;
- private void DateTimePickerStar_ValueChanged(object sender, EventArgs e)
- {
- if (!this.PanelDataView.DataRowList.Any(r => r.DataColumnList.Any(c => c.CellIndex == 0 && c.DateTimeTag.ToString("yyyy-MM-dd") == this.dateTimePickerStar.Value.ToString("yyyy-MM-dd"))))
- {
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- }
- else if(isNowWeek)
- {
- isNowWeek = false;
- this.LoadCameraControlTemplate();
- this.BindPanelDataView();
- }
- }
- /// <summary>
- /// 本周
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnNearlyOneWeek_Click(object sender, EventArgs e)
- {
- this.dateTimePickerStar.Value = SDateTime.Now;
- isNowWeek = true;
- }
- /// <summary>
- /// 上一周
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnBeforeDay_Click(object sender, EventArgs e)
- {
- this.dateTimePickerStar.Value = this.dateTimePickerStar.Value.AddDays(-7);
-
- }
- /// <summary>
- /// 下一周
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnAfterDay_Click(object sender, EventArgs e)
- {
- this.dateTimePickerStar.Value = this.dateTimePickerStar.Value.AddDays(7);
-
- }
- #endregion
- #region 门店列表处理
- QueryStoreInfo GetCurrentStoreInfo()
- {
- if (CurrentQueryStoreList != null&& CurrentQueryStoreList.QueryStoreInfoList.Count > 0)
- {
- return CurrentQueryStoreList.QueryStoreInfoList[0];
- }
- return new QueryStoreInfo {
- DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID
- , DividedShop_Name = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CompanyName
- };
- }
- /// <summary>
- /// 当前要查询的门店信息集合
- /// </summary>
- public QueryStoreList CurrentQueryStoreList = null;
- public EnumPermissions.BusinessType GetCurrentStoreBusinessType()
- {
- if (CurrentQueryStoreList != null)
- {
- return GetStoreBusinessType(CurrentQueryStoreList);
- }
- else {
- return LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType();
- }
- }
- public static EnumPermissions.BusinessType GetStoreBusinessType(QueryStoreList storeList)
- {
- if (storeList.QueryStoreInfoList.Count > 0)
- {
- return GetStoreBusinessType(storeList.QueryStoreInfoList[0]);
- }
- return LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType();
- }
- public static EnumPermissions.BusinessType GetStoreBusinessType(QueryStoreInfo storeInfo)
- {
- EnumPermissions.BusinessType buType = (EnumPermissions.BusinessType)storeInfo.ShopStoreFeature.BusinessType;
- return buType;
- }
- #endregion
- }
- }
|