public Common.Entity.ReturnValueInfo InsertRecord(NoticeManage_Info reasonInfo) { throw new NotImplementedException(); }
/// <summary> /// 檢驗數據是否可以保存 /// </summary> /// <returns></returns> private NoticeManage_Info CheckData() { string content=this.rtbContent.Text; if (String.IsNullOrEmpty(this.rtbContent.Text.Trim())) { MessageBox.Show(this, "請輸入通告內容"); return null; } else { DateTime startDate = DateTime.Parse(this.dtpStartDate.Text); DateTime endDate = DateTime.Parse(this.dtpEndDate.Text); DateTime validFrom = DateTime.Parse(this.dtpValidFrom.Text); DateTime validTo = DateTime.Parse(this.dtpValidTo.Text); int scrollSpeed = Int32.Parse(this.nudScrollSpeed.Value.ToString()); string dateIndex = ""; bool Sync = this.chbSync.Checked; bool Valid = this.chbValid.Checked; int periodType = 0 ; if (endDate < startDate) { MessageBox.Show(this, "有效期的開始日期不能大于結束日期,請檢查!"); return null; } if (validFrom >= validTo) { MessageBox.Show(this, "顯示時間段的開始時間不能大于或等於結束時間,請檢查!"); return null; } if (this.rbtDate.Checked == true) { periodType = 1; } else if (this.rbtWeek.Checked == true) { periodType = 2; List<CheckBox> weekList = GetWeekList(); for (int index = 0; index < weekList.Count; index++) { if (weekList[index].Checked) { dateIndex += (index+1)+","; } } if (dateIndex != "") { dateIndex = dateIndex.Substring(0, dateIndex.Length - 1); } else { return null; } } NoticeManage_Info notInfo = new NoticeManage_Info(); notInfo.not_dEndDate = endDate; notInfo.not_dStartDate = startDate; notInfo.not_dValidFrom = validFrom; notInfo.not_dValidTo = validTo; notInfo.not_iPeriodType = periodType; notInfo.not_iScrollSpeed = scrollSpeed; notInfo.not_cContent = content; notInfo.not_lValid = Valid; notInfo.not_lSync = Sync; //notInfo.not_cAdd = this.UserInformation.usm_cUserLoginID; notInfo.not_cAdd = "System"; notInfo.not_dAddDate = System.DateTime.Now; //notInfo.not_cLast = this.UserInformation.usm_cUserLoginID; notInfo.not_cLast = "System"; notInfo.not_dLastDate = System.DateTime.Now; notInfo.not_cDateIndex = dateIndex; if (this.lbxSelectedMachine.Items.Count > 0) { List<NoticeToMachine> ntmList = new List<NoticeToMachine>(); for (int index = 0; index < this.lbxSelectedMachine.Items.Count; index++) { MachineMaster_mmt_Info machine = this.lbxSelectedMachine.Items[index] as MachineMaster_mmt_Info; NoticeToMachine noticeToMachine = new NoticeToMachine(); noticeToMachine.notm_ReocordId = Guid.NewGuid(); noticeToMachine.notm_cMMTID = machine.mmt_cMachineID; ntmList.Add(noticeToMachine); } notInfo.NoticeMachineList = ntmList; } else { MessageBox.Show(this, "請選擇需要顯示通告的印刷機!"); return null; } return notInfo; } }
private void lvInfo_SelectedIndexChanged(object sender, EventArgs e) { ListDataView view = sender as ListDataView; if (view != null && view.SelectedItems.Count > 0) { this.SysToolBar.BtnDelete_IsEnabled = true; this.SysToolBar.BtnDetail_IsEnabled = true; this.SysToolBar.BtnModify_IsEnabled = true; int infoID = view.SelectedItems[0].Index;// as NoticeManage_Info; _noticeInfo = _showDataList[infoID]; } else { this.SysToolBar.BtnDelete_IsEnabled = false; this.SysToolBar.BtnDetail_IsEnabled = false; this.SysToolBar.BtnModify_IsEnabled = false; _noticeInfo = null; } }
/// <summary> /// 打開通告窗口 /// </summary> /// <param name="noticeInfo"></param> /// <param name="stateEnum"></param> private void OpenNoticeInfo(NoticeManage_Info noticeInfo,Common.DefineConstantValue.EditStateEnum stateEnum) { MenuItem itemMenu = new MenuItem(); itemMenu.Tag = "WindowUI.HBManagerTerminal.Management.RunningManagement.NoticeManageSet"; BaseForm form=this.ShowSubForm(itemMenu, this.BaseDockPanel, "", WeifenLuo.WinFormsUI.Docking.DockState.Document, noticeInfo, stateEnum); form.FromCloseCallBack += BingGv; }
/// <summary> /// 生成每周通告 /// </summary> /// <param name="reasonInfo"></param> /// <returns></returns> private bool BuildWeeksNotice(NoticeManage_Info reasonInfo) { try { string startDate = ((DateTime)(reasonInfo.not_dStartDate)).ToString("yyyy-MM-dd"); string endDate = ((DateTime)(reasonInfo.not_dEndDate)).ToString("yyyy-MM-dd"); string timeForm = reasonInfo.not_dValidFrom.ToString("HH:mm:ss"); string timeTo = reasonInfo.not_dValidTo.ToString("HH:mm:ss"); System.TimeSpan ts = ((DateTime)(reasonInfo.not_dEndDate)).Subtract(((DateTime)(reasonInfo.not_dStartDate)));//TimeSpan得到dt1和dt2的时间间隔 int countday = ts.Days;// if (timeForm == timeTo) { reasonInfo.not_dValidTo = reasonInfo.not_dValidTo.AddMinutes(5); timeTo = reasonInfo.not_dValidTo.ToString("HH:mm:ss"); } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("nol_iRecordID", typeof(int))); dt.Columns.Add(new DataColumn("nol_NOTID", typeof(System.Guid))); dt.Columns.Add(new DataColumn("nol_iMMTID", typeof(string))); dt.Columns.Add(new DataColumn("nol_dStartDate", typeof(DateTime))); dt.Columns.Add(new DataColumn("nol_dEndData", typeof(DateTime))); List<NoticeToMachine> ntmList = GetNoticeMachineList(reasonInfo.not_RecordID.ToString()); if (ntmList != null && ntmList.Count > 0) { string[] dateIndexs = reasonInfo.not_cDateIndex.Split(','); for (int n = 0; n < dateIndexs.Length;n++ ) { DateTime date = ((DateTime)(reasonInfo.not_dStartDate)); date = GetWeekDateTime(date, dateIndexs[n]); foreach (NoticeToMachine ntmObj in ntmList) { if (countday > 0) { while (date < reasonInfo.not_dEndDate) { startDate = date.ToString("yyyy-MM-dd"); DataRow dr = dt.NewRow(); dr["nol_iRecordID"] = (int)0; dr["nol_NOTID"] = reasonInfo.not_RecordID; dr["nol_iMMTID"] = ntmObj.notm_cMMTID; dr["nol_dStartDate"] = DateTime.Parse(startDate + " " + timeForm); dr["nol_dEndData"] = DateTime.Parse(startDate + " " + timeTo); dt.Rows.Add(dr); date = date.AddDays(7); } } } dt.TableName = "NoticeList_nol"; } DeleteNoticeList(reasonInfo.not_RecordID); InsertDataTable(dt); } } catch { throw; } return false; }
public ReturnValueInfo DeleteRecord(NoticeManage_Info reasonInfo) { return null; }
public ReturnValueInfo UpdateRecord(NoticeManage_Info reasonInfo) { try { return this._INoticeManageDA.UpdateRecord(reasonInfo); } catch (Exception ex) { throw ex; } }
/// <summary> /// 生成一次通告 /// </summary> /// <param name="reasonInfo"></param> /// <returns></returns> private bool BuildOnceNotice(NoticeManage_Info reasonInfo) { try { string date = ((DateTime)(reasonInfo.not_dStartDate)).ToString("yyyy-MM-dd"); string timeForm = reasonInfo.not_dValidFrom.ToString("HH:mm:ss"); string timeTo = reasonInfo.not_dValidTo.ToString("HH:mm:ss"); if(timeForm == timeTo ) { reasonInfo.not_dValidTo = reasonInfo.not_dValidTo.AddMinutes(5); timeTo = reasonInfo.not_dValidTo.ToString("HH:mm:ss"); } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("nol_iRecordID", typeof(int))); dt.Columns.Add(new DataColumn("nol_NOTID", typeof(System.Guid))); dt.Columns.Add(new DataColumn("nol_iMMTID", typeof(string))); dt.Columns.Add(new DataColumn("nol_dStartDate",typeof(DateTime))); dt.Columns.Add(new DataColumn("nol_dEndData", typeof(DateTime))); List<NoticeToMachine> ntmList = GetNoticeMachineList(reasonInfo.not_RecordID.ToString()); if (ntmList != null && ntmList.Count > 0) { foreach (NoticeToMachine ntmObj in ntmList) { DataRow dr = dt.NewRow(); dr["nol_iRecordID"] =(int) 0; dr["nol_NOTID"] = reasonInfo.not_RecordID; dr["nol_iMMTID"] = ntmObj.notm_cMMTID; dr["nol_dStartDate"] = DateTime.Parse(date + " " + timeForm); dr["nol_dEndData"] = DateTime.Parse(date + " " + timeTo); dt.Rows.Add(dr); } } DeleteNoticeList(reasonInfo.not_RecordID); dt.TableName = "NoticeList_nol"; InsertDataTable(dt); return true; } catch { } return false; }
public List<NoticeManage_Info> SearchRecord(NoticeManage_Info searchInfo) { try { return _INoticeManageDA.SearchRecord(searchInfo); } catch (Exception ex) { throw ex; } }
public bool InsertNoticeMessage(NoticeManage_Info reasonInfo) { if(reasonInfo != null) { switch(reasonInfo.not_iPeriodType) { case 0 : BuildOnceNotice(reasonInfo); break; case 1 : BuildDatesNotice(reasonInfo); break; case 2 : BuildWeeksNotice(reasonInfo); break; default: break; } } return false; }
public ReturnValueInfo UpdateRecord(NoticeManage_Info reasonInfo) { ReturnValueInfo returnValue = new ReturnValueInfo(); if(reasonInfo != null) { try { using (MainDBDataContext db = new MainDBDataContext()) { NoticeManage_not query = db.NoticeManage_not.SingleOrDefault(t => t.not_RecordID == reasonInfo.not_RecordID); if (query != null) { query.not_cContent = reasonInfo.not_cContent; query.not_cDateIndex = reasonInfo.not_cDateIndex; query.not_dLastDate = System.DateTime.Now; query.not_dValidFrom = reasonInfo.not_dValidFrom; query.not_dValidTo = reasonInfo.not_dValidTo; query.not_iPeriodType = reasonInfo.not_iPeriodType; query.not_iScrollSpeed = reasonInfo.not_iScrollSpeed; query.not_lSync = reasonInfo.not_lSync; query.not_lValid = reasonInfo.not_lValid; db.SubmitChanges(); } var ret = from notm in db.NoticeMachine_notm where notm.notm_NOTID == reasonInfo.not_RecordID select notm; if(ret.Count() > 0) { db.NoticeMachine_notm.DeleteAllOnSubmit(ret); db.SubmitChanges(); } if (reasonInfo.NoticeMachineList != null && reasonInfo.NoticeMachineList.Count > 0) { foreach (NoticeToMachine noticeMachine in reasonInfo.NoticeMachineList) { noticeMachine.notm_NOTID = reasonInfo.not_RecordID; LinqToSQLModel.NoticeMachine_notm machine = Common.General.CopyObjectValue<Model.HBPMS.Master.NoticeToMachine, LinqToSQLModel.NoticeMachine_notm>(noticeMachine); db.NoticeMachine_notm.InsertOnSubmit(machine); } db.SubmitChanges(); } returnValue.boolValue = true; returnValue.isError = false; returnValue.ValueObject = query; returnValue.messageText = "保存成功"; } } catch (Exception Ex) { throw Ex; } } return returnValue; }
public List<NoticeManage_Info> SearchRecord(NoticeManage_Info searchInfo) { List<NoticeManage_Info> listReturn = new List<NoticeManage_Info>(); try { NoticeManage_Info srmSearchInfo = searchInfo as NoticeManage_Info; StringBuilder sbSQL = new StringBuilder(); sbSQL.AppendLine("select * from dbo.NoticeManage_not where 1=1 "); StringBuilder sbWhere = new StringBuilder(); if(!string.IsNullOrEmpty(srmSearchInfo.not_cAdd)) { sbWhere.AppendLine(" and [not_cAdd] = '" + srmSearchInfo.not_cAdd + "'"); } if(!string.IsNullOrEmpty(srmSearchInfo.not_cContent)) { sbWhere.AppendLine(" and [not_cContent] like '%" + srmSearchInfo.not_cContent + "%'"); } IEnumerable<NoticeManage_Info> infos = null; using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<NoticeManage_Info>(sbSQL.ToString() + sbWhere.ToString(), new object[] { }); if (infos != null) { listReturn = infos.ToList(); } } } catch (Exception ex) { throw ex; } return listReturn; }
public ReturnValueInfo InsertRecord(NoticeManage_Info reasonInfo) { ReturnValueInfo returnValue = new ReturnValueInfo(); if (reasonInfo != null) { try { using (MainDBDataContext db = new MainDBDataContext()) { reasonInfo.not_RecordID = Guid.NewGuid(); LinqToSQLModel.NoticeManage_not newTab = Common.General.CopyObjectValue<Model.HBPMS.Master.NoticeManage_Info, LinqToSQLModel.NoticeManage_not>(reasonInfo); db.NoticeManage_not.InsertOnSubmit(newTab); db.SubmitChanges(); if (reasonInfo.NoticeMachineList != null && reasonInfo.NoticeMachineList.Count > 0) { foreach (NoticeToMachine noticeMachine in reasonInfo.NoticeMachineList) { noticeMachine.notm_NOTID = reasonInfo.not_RecordID; LinqToSQLModel.NoticeMachine_notm machine = Common.General.CopyObjectValue<Model.HBPMS.Master.NoticeToMachine, LinqToSQLModel.NoticeMachine_notm>(noticeMachine); db.NoticeMachine_notm.InsertOnSubmit(machine); } db.SubmitChanges(); } returnValue.boolValue = true; returnValue.isError = false; returnValue.ValueObject = newTab; returnValue.messageText = "保存成功"; } } catch (Exception Ex) { throw Ex; } } else { returnValue.boolValue = false; returnValue.isError = true; returnValue.messageText = "保存的對象為空"; } return returnValue; }