private void CancelFormatChanges() { if (cancelFormatChangesSimpleButton.Tag.ToString() == "New Format") { if (m_CurrentLotCodeFormat.Oid > 0) { m_CurrentLotCodeFormat.Delete(); } else { m_CurrentLotCodeFormat = null; } m_CurrentLotCodeSection = null; m_CurrentLotCodeSectionSettings = null; sectionSettingsPanelControl.Enabled = false; lotCodeFormatPreviewGroupControl.Enabled = false; formatNameTextEdit.EditValue = null; formatSectionsSpinEdit.EditValue = 1; formatWarningLabelControl.Visible = false; PrepareNewLotCodeSection(null); } else { BindLotCodeFormat(m_CurrentLotCodeFormat.Oid); } }
private void BindLotCodeSectionFields(int SectionID) { m_CurrentLotCodeSection = m_LotCodeSession.GetObjectByKey <LotCodeFormatSections>(SectionID, true); sectionPositionSpinEdit.EditValue = m_CurrentLotCodeSection.SectionPosition; sectionPositionSpinEdit.ReadOnly = true; sectionNameTextEdit.EditValue = m_CurrentLotCodeSection.SectionName; sectionTypeImageComboBoxEdit.EditValue = m_CurrentLotCodeSection.SectionType; sectionLengthSpinEdit.EditValue = m_CurrentLotCodeSection.SectionLength; foreach (LotCodeSectionSettings sectionSetting in m_CurrentLotCodeSection.SectionSettings) { switch (sectionSetting.SettingName) { case "LettersToSkip": lettersToSkipTextEdit.EditValue = sectionSetting.SettingValue; break; case "LettersToReplace": lettersToReplaceTextEdit.EditValue = sectionSetting.SettingValue; break; case "ReplacementLetters": replacementLettersTextEdit.EditValue = sectionSetting.SettingValue; break; case "FirstMonth": firstMonthComboBoxEdit.EditValue = sectionSetting.SettingValue; break; case "FirstYear": firstYearTextEdit.EditValue = sectionSetting.SettingValue; break; case "FirstWeekOfYear": firstWeekOfYearImageComboBoxEdit.EditValue = sectionSetting.SettingValue; break; case "FirstDayOfWeek": firstDayOfWeekImageComboBoxEdit.EditValue = sectionSetting.SettingValue; break; case "RestartsOnThe": restartsOnTextEdit.EditValue = sectionSetting.SettingValue; break; case "NumberRangeFrom": fromSpinEdit.EditValue = sectionSetting.SettingValue; break; case "NumberRangeTo": toSpinEdit.EditValue = sectionSetting.SettingValue; break; default: //Unknown setting break; } } }
private void PrepareNewLotCodeSection(int?SectionPosition) { if (SectionPosition.HasValue) { m_CurrentLotCodeSection = m_LotCodeSession.FindObject <LotCodeFormatSections>(new GroupOperator(GroupOperatorType.And, new BinaryOperator(LotCodeFormatSections.Fields.LotCodeFormat.Oid.PropertyName, m_CurrentLotCodeFormat.Oid, BinaryOperatorType.Equal), new BinaryOperator(LotCodeFormatSections.Fields.SectionPosition.PropertyName, SectionPosition.Value, BinaryOperatorType.Equal))); if (m_CurrentLotCodeSection == null) { m_CurrentLotCodeSection = new LotCodeFormatSections(m_LotCodeSession) { SectionPosition = SectionPosition.Value, LotCodeFormat = m_CurrentLotCodeFormat }; } else { BindLotCodeSectionFields(m_CurrentLotCodeSection.Oid); return; } sectionPositionSpinEdit.EditValue = SectionPosition.Value; } else { sectionPositionSpinEdit.EditValue = 1; } sectionNameTextEdit.EditValue = null; sectionTypeImageComboBoxEdit.EditValue = null; sectionLengthSpinEdit.EditValue = 1; lettersToSkipTextEdit.EditValue = null; lettersToReplaceTextEdit.EditValue = null; replacementLettersTextEdit.EditValue = null; firstMonthComboBoxEdit.EditValue = null; firstYearTextEdit.EditValue = null; firstWeekOfYearImageComboBoxEdit.EditValue = null; firstDayOfWeekImageComboBoxEdit.EditValue = null; restartsOnTextEdit.EditValue = null; fromSpinEdit.EditValue = 11; toSpinEdit.EditValue = 99; }
private void newLotCodeFormatSimpleButton_Click(object sender, EventArgs e) { m_CurrentLotCodeFormat = new LotCodeFormats(m_LotCodeSession); cancelFormatChangesSimpleButton.Tag = "New Format"; m_CurrentLotCodeSection = null; m_CurrentLotCodeSectionSettings = null; sectionSettingsPanelControl.Enabled = false; lotCodeFormatPreviewGroupControl.Enabled = false; formatNameTextEdit.EditValue = null; formatSectionsSpinEdit.EditValue = 1; formatWarningLabelControl.Visible = false; formatNameTextEdit.ReadOnly = false; formatSectionsSpinEdit.ReadOnly = false; PrepareNewLotCodeSection(null); CheckPermissions(); cancelFormatChangesSimpleButton.Enabled = true; saveFormatSimpleButton.Enabled = true; editLotCodeFormatSimpleButton.Enabled = false; newLotCodeFormatSimpleButton.Enabled = false; lotCodeFormatSectionsGridControl.Enabled = false; }
public static bool ValidateByItem(Items item, string lot, bool ValidateFormat) { SortingCollection sortCollection = new SortingCollection(); LotCodeFormatSections codeSection = null; //INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#: // Dim sectionSettings As LotCodeSectionSettings string sectionValue = null; int sectionValueNum = 0; int valuePosition = 0; if (!(item.RequiresLotCodes ?? false)) { return(true); } if ((lot == null) || string.IsNullOrEmpty(lot)) { return(false); } if (!ValidateFormat) { return(true); } if (item.DefaultLotCodeFormat == null) { return(true); } sortCollection.Add(new SortProperty("SectionPosition", DevExpress.Xpo.DB.SortingDirection.Ascending)); item.DefaultLotCodeFormat.FormatSections.Sorting = sortCollection; foreach (LotCodeFormatSections codeSectionWithinLoop in item.DefaultLotCodeFormat.FormatSections) { codeSection = codeSectionWithinLoop; if (lot.Length < valuePosition + codeSectionWithinLoop.SectionLength) { return(false); } sectionValue = lot.Substring(valuePosition, codeSectionWithinLoop.SectionLength); foreach (LotCodeSectionSettings sectionSettings in codeSectionWithinLoop.SectionSettings) { if (sectionSettings.SettingName == "NumberRangeFrom") { if (!int.TryParse(sectionValue, out sectionValueNum) || sectionValueNum < int.Parse(sectionSettings.SettingValue)) { return(false); } } if (sectionSettings.SettingName == "NumberRangeTo") { if (!int.TryParse(sectionValue, out sectionValueNum) || sectionValueNum > int.Parse(sectionSettings.SettingValue)) { return(false); } } } valuePosition += codeSectionWithinLoop.SectionLength; } return(true); }