private void FrmLogon_Load(object sender, EventArgs e) { string strImgWelcome2 = ""; strImgWelcome2 = CommonFunction.GetSysImg("2"); string strImgWelcome3 = ""; strImgWelcome3 = CommonFunction.GetSysImg("3"); picBoxLogo.Image = File.Exists(strImgWelcome2) ? Image.FromFile(strImgWelcome2) : null; picBoxLogoCust.Image = File.Exists(strImgWelcome3) ? Image.FromFile(strImgWelcome3) : null; //lblDate.Text = ""; //lblTime.Text = ""; //lblSession.Text = ""; lblDate.Text = DateTime.Now.ToShortDateString(); lblTime.Text = DateTime.Now.ToLongTimeString(); new OnLoadSystemCommonData().GetShiftCodeList(); ShiftCodeInfo scInfo = new ShiftCodeInfo(); scInfo = CommonData.ShiftCodeList.FirstOrDefault(sc => DateTime.Compare(Convert.ToDateTime(DateTime.Now.ToShortTimeString()), Convert.ToDateTime(sc.DtFrom)) >= 0 && DateTime.Compare(Convert.ToDateTime(DateTime.Now.ToShortTimeString()), Convert.ToDateTime(sc.DtTo)) <= 0); if (scInfo != null) { lblSession.Text = scInfo.ShiftName; } //foreach (var sc in CommonData.ShiftCodeList) //{ // Console.WriteLine(@"SystemKey:" + sc.SystemKey // + @" Shift Code:" + sc.ShiftCode // + @" Shift Name:" + sc.ShiftName // + @" Other Name:" + sc.OtherName // + @" DtFrom: " + sc.DtFrom // + @" DtTo: " + sc.DtTo // + @" SpecialPriceEnable: " + sc.SpecialPriceEnable); //} }
private void FrmSelectMenu_Load(object sender, EventArgs e) { txtDate.Text = DateTime.Now.ToShortDateString(); txtTime.Text = DateTime.Now.ToLongTimeString(); new OnLoadSystemCommonData().GetShiftCodeList(); ShiftCodeInfo scInfo = new ShiftCodeInfo(); scInfo = CommonData.ShiftCodeList.FirstOrDefault(sc => DateTime.Compare(Convert.ToDateTime(DateTime.Now.ToShortTimeString()), Convert.ToDateTime(sc.DtFrom)) >= 0 && DateTime.Compare(Convert.ToDateTime(DateTime.Now.ToShortTimeString()), Convert.ToDateTime(sc.DtTo)) <= 0); if (scInfo != null) { txtSession.Text = scInfo.ShiftName; } txtStaff.Text = userInfo.UsrName; OnLoadSystemCommonData onLoadSystemCommonData = new OnLoadSystemCommonData(); onLoadSystemCommonData.GetSysControlList(); string strImg = ""; if (CommonData.SysControlList.Any()) { sysControlInfo = CommonData.SysControlList.FirstOrDefault(); } else { MessageBox.Show("S001:System data error,Please contact system Administrator!"); Close(); } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtShiftCode.Text.Trim())) { MessageBox.Show("Shift code is empty,please enter!"); return; } if (string.IsNullOrEmpty(txtShiftName.Text.Trim())) { MessageBox.Show("Shift name is empty,please enter!"); return; } if (string.IsNullOrEmpty(txtOtherName.Text.Trim())) { MessageBox.Show("Other name is empty,please enter!"); return; } //验证时间 if ( !CommonData.ShiftCodeList.Any( sc => TimeCompare(Convert.ToDateTime(dtpFrom.Text), Convert.ToDateTime(dtpTo.Text), Convert.ToDateTime(sc.DtFrom), Convert.ToDateTime(sc.DtTo)))) { MessageBox.Show("Time setting error, please re-enter!"); return; } var shiftCodeInfo = new ShiftCodeInfo(); shiftCodeInfo.ShiftCode = Convert.ToInt32(txtShiftCode.Text.Trim()); shiftCodeInfo.ShiftName = txtShiftName.Text.Trim(); shiftCodeInfo.OtherName = txtOtherName.Text.Trim(); shiftCodeInfo.DtFrom = dtpFrom.Value.ToShortTimeString(); shiftCodeInfo.DtTo = dtpTo.Value.ToShortTimeString(); shiftCodeInfo.SpecialEnable = chkBoxEnable.Checked ? 1 : 0; shiftCodeInfo.SpecialContent = ""; var sb = new StringBuilder(); sb.Append(","); if (chkBoxMonday.Checked) { sb.Append("1,"); } if (chkBoxTuesday.Checked) { sb.Append("2,"); } if (chkBoxWednesday.Checked) { sb.Append("3,"); } if (chkBoxThursday.Checked) { sb.Append("4,"); } if (chkBoxFriday.Checked) { sb.Append("5,"); } if (chkBoxSaturday.Checked) { sb.Append("6,"); } if (chkBoxSunday.Checked) { sb.Append("7,"); } shiftCodeInfo.SpecialContent = sb.ToString(); if (iStatus == 1) { shiftCodeInfo.SystemKey = new Guid(Guid.NewGuid().ToString().ToUpper()); _control.AddEntity(shiftCodeInfo); } else //iStatus == 2 { if (dgvShiftCode.CurrentRow != null) { shiftCodeInfo.SystemKey = new Guid(dgvShiftCode.CurrentRow.Cells[0].Value.ToString()); } _control.UpdateEntity(shiftCodeInfo); } //_control.AddEntity(shiftCodeInfo); //_control.SaveOrUpdateEntity(shiftCodeInfo); new OnLoadSystemCommonData().GetShiftCodeList(); dgvShiftCode.DataSource = CommonData.ShiftCodeList; //dgvShiftCode.Refresh(); ControlStatus(0); iStatus = 0; btnSave.Enabled = false; btnAdd.Enabled = true; btnEdit.Enabled = true; btnDel.Enabled = true; }