QER.Forms/QER.Forms/FormDelegationMasterData.cs
Decompiler Source FileQER.Forms.FormDelegationMasterDataDecompiled Source
Interpretation
- Decompiled source file. Use method/event registrations and call-site extraction to connect back to DialogMethod, QBMEvent, and API layers.
Relations
- CallMethod: Abort at line 94
Typed Edges
- No typed edges extracted for this source.
References
- No direct source references extracted.
Referenced By
- No direct source references extracted.
Complete Source
1using System;2using System.Windows.Forms;3using VI.Base;4using VI.Controls;5using VI.Controls.Interfaces;6using VI.DB;7using VI.DB.Compatibility;8using VI.DB.Entities;9using VI.DB.MetaData;10using VI.DB.Sync;11using VI.FormBase;12using VI.FormBase.Tasks;13using VI.FormTools;14using VI.ImageLibrary;1516namespace QER.Forms;1718public class FormDelegationMasterData : BaseCustomizer19{20 private IActivatorComponent m_MainActivator;2122 private ICheckBox m_CheckBoxIsDelegable;2324 private ICheckBox m_CheckBoxKeepMeInformed;2526 private IDateButton m_ButtonValidFrom;2728 private IDateButton m_ButtonValidTo;2930 private IEdit m_EditOrderState;3132 private IEdit m_EditValidFrom;3334 private IEdit m_EditValidTo;3536 private IHorizFormBar m_FormHeader;3738 private ILinkComboBox m_FKLinkUIDPersonWantsOrg;3940 private ITreeComboBox m_TreeComboBoxDelegationDelegableElement;4142 private ITreeComboBox m_TreeComboUIDPersonReceiver;4344 private ITreeComboBox m_TreeComboUIDPersonSender;4546 private IVIPanel m_MainPanel;4748 private IObjectChangeComponent m_ObjectChangeComponent;4950 protected override void OnInit()51 {52 m_ButtonValidFrom = base.Form.GetControl<IDateButton>("ButtonValidFrom");53 m_ButtonValidTo = base.Form.GetControl<IDateButton>("ButtonValidTo");54 m_CheckBoxIsDelegable = base.Form.GetControl<ICheckBox>("CheckBoxIsDelegable");55 m_CheckBoxKeepMeInformed = base.Form.GetControl<ICheckBox>("CheckBoxKeepMeInformed");56 m_EditOrderState = base.Form.GetControl<IEdit>("EditOrderState");57 m_EditValidFrom = base.Form.GetControl<IEdit>("EditValidFrom");58 m_EditValidTo = base.Form.GetControl<IEdit>("EditValidTo");59 m_FKLinkUIDPersonWantsOrg = base.Form.GetControl<ILinkComboBox>("FKLinkUIDPersonWantsOrg");60 m_FormHeader = base.Form.GetControl<IHorizFormBar>("FormHeader");61 m_MainActivator = base.Form.GetComponent<IActivatorComponent>("MainActivator");62 m_MainPanel = base.Form.GetControl<IVIPanel>("MainPanel");63 m_ObjectChangeComponent = base.Form.GetComponent<IObjectChangeComponent>("ObjectChangeComponent");64 m_TreeComboBoxDelegationDelegableElement = base.Form.GetControl<ITreeComboBox>("TreeComboBoxDelegationDelegableElement");65 m_TreeComboUIDPersonReceiver = base.Form.GetControl<ITreeComboBox>("TreeComboUIDPersonReceiver");66 m_TreeComboUIDPersonSender = base.Form.GetControl<ITreeComboBox>("TreeComboUIDPersonSender");67 }6869 private void InitializeComponent()70 {71 }7273 protected override void OnFormLoad()74 {75 m_TreeComboBoxDelegationDelegableElement.Caption = "QER_FormDelegationMasterData_DelegationDelegableElement";76 using (new UpdateHelper(base.Tasks))77 {78 Task task = base.Tasks["Abort"];79 task.TaskMethod = TaskAbort;80 task.Caption = "QER_FormDelegationMasterData_Task_DelegationAbort";81 task.StockImage = StockImage.RedDelete;82 task.Enabled = false;83 task.Visible = true;84 }85 }8687 public void TaskAbort()88 {89 //IL_001b: Unknown result type (might be due to invalid IL or missing references)90 //IL_0021: Invalid comparison between Unknown and I491 ISingleDbObject dbObject = m_MainActivator.DbObject;92 if (dbObject != null && (int)FormTool.ShowQuestion("QER_FormDelegationMasterData_Question_AbortDelegation", (MessageBoxButtons)4) == 6)93 {94 dbObject.Custom.CallMethod("Abort", BaseCustomizer.GetString("QER_FormDelegationMasterData_DelegationDefaultAbortReason"));95 dbObject.Save();96 dbObject.Load();97 base.Tasks["Abort"].Enabled = false;98 }99 }100101 private void MainActivator_OnActivating(object sender, EventArgs e)102 {103 ISingleDbObject dbObject = m_MainActivator.DbObject;104 if (dbObject != null)105 {106 if (!dbObject.IsLoaded && dbObject["UID_PersonSender"].New.String.Length == 0)107 {108 dbObject["UID_PersonSender"].NewValue = base.Session.User().Uid;109 }110 m_EditValidTo.EnabledByUser = !dbObject.IsLoaded;111 m_EditValidFrom.EnabledByUser = !dbObject.IsLoaded;112 IMetaTable table = base.Session.MetaData().GetTable("PersonWantsOrg");113 m_EditValidFrom.Caption = table.Columns["ValidFrom"].Display.Translated;114 m_EditValidTo.Caption = table.Columns["ValidUntil"].Display.Translated;115 }116 }117118 private void _AdaptTasks()119 {120 try121 {122 ISingleDbObject dbObject = m_MainActivator.DbObject;123 using (new UpdateHelper(base.Tasks))124 {125 string valueSafe = dbObject.GetValueSafe("OrderState", "---");126 base.Tasks["Abort"].Enabled = dbObject != null && string.Compare(dbObject.GetValueSafe("UID_PersonSender", "---"), base.Session.User().Uid, (StringComparison)5) == 0 && string.Compare(valueSafe, "Aborted", (StringComparison)5) != 0 && string.Compare(valueSafe, "Dismissed", (StringComparison)5) != 0 && string.Compare(valueSafe, "Unsubscribed", (StringComparison)5) != 0;127 base.Tasks["Abort"].Visible = dbObject?.IsLoaded ?? false;128 }129 }130 catch (System.Exception exception)131 {132 base.Tasks["Abort"].Enabled = false;133 ExceptionMgr.Instance.HandleException(exception, this);134 }135 }136137 private void ObjectChangeComponent_ColumnValueChanged(object sender, ColumnEventArgs e)138 {139 ISingleDbObject dbObject = m_MainActivator.DbObject;140 if (dbObject == null)141 {142 return;143 }144 try145 {146 string text = e.Column.Columnname.ToLowerInvariant();147 if (!(text == "uid_personsender"))148 {149 if (!(text == "uid_personreceiver"))150 {151 if (!(text == "uid_personwantsorg"))152 {153 IEntity entity;154 if (!(text == "objectkeydelegated"))155 {156 if (text == "orderstate")157 {158 _AdaptTasks();159 }160 }161 else if (e.New.String.Length == 0)162 {163 m_TreeComboBoxDelegationDelegableElement.SelectedParent = null;164 }165 else if (base.Session.Source().TryGet(Query.From("QERVDelegableItem").Where(base.SqlFormatter.UidComparison("ObjectKeyToDelegate", e.New.String)).SelectNone(), EntityLoadType.Interactive, out entity))166 {167 m_TreeComboBoxDelegationDelegableElement.SelectedParent = entity.CreateSingleDbObject(base.Session);168 }169 }170 else171 {172 ISingleDbObject singleDbObject = dbObject.GetFK("uid_personwantsorg").Create();173 System.DateTime dateTime = singleDbObject?.GetValueSafe("ValidFrom", DbVal.MinDate) ?? DbVal.MinDate;174 m_EditValidFrom.Text = ((dateTime == DbVal.MinDate) ? "" : dateTime.ToShortDateString());175 dateTime = singleDbObject?.GetValueSafe("ValidUntil", DbVal.MinDate) ?? DbVal.MinDate;176 m_EditValidTo.Text = ((dateTime == DbVal.MinDate) ? "" : dateTime.ToShortDateString());177 }178 }179 else180 {181 m_TreeComboUIDPersonSender.WhereClause = base.SqlFormatter.AndRelation(base.SqlFormatter.OrRelation(base.SqlFormatter.UidComparison("UID_Person", base.Session.User().Uid), string.Format("UID_Person in (select UID_Person from HelperHeadPerson where {0})", (object)base.SqlFormatter.UidComparison("UID_PersonHead", base.Session.User().Uid))), base.SqlFormatter.UidComparison("UID_Person", e.New.String, CompareOperator.NotEqual));182 }183 }184 else185 {186 m_TreeComboUIDPersonReceiver.WhereClause = base.SqlFormatter.UidComparison("UID_Person", e.New.String, CompareOperator.NotEqual);187 m_TreeComboBoxDelegationDelegableElement.WhereClause = base.SqlFormatter.UidComparison("UID_Person", e.New.String);188 _AdaptTasks();189 }190 }191 catch (System.Exception exception)192 {193 ExceptionMgr.Instance.HandleException(exception, this);194 }195 }196197 private void MainActivator_Saving(object sender, EventArgs e)198 {199 ISingleDbObject dbObject = m_MainActivator.DbObject;200 if (dbObject == null || dbObject.IsLoaded)201 {202 return;203 }204 string valueSafe = dbObject.GetValueSafe("ObjectKeyDelegated", "");205 if (valueSafe == "")206 {207 throw new ViException(2235029);208 }209 System.DateTime dateTime = DbVal.MinDate;210 System.DateTime dateTime2 = System.DateTime.MaxValue;211 try212 {213 if (m_EditValidFrom.Text.Trim().Length > 0)214 {215 dateTime = System.DateTime.Parse(m_EditValidFrom.Text.Trim(), (IFormatProvider)(object)LanguageManager.Culture);216 }217 if (m_EditValidTo.Text.Trim().Length > 0)218 {219 dateTime2 = System.DateTime.Parse(m_EditValidTo.Text.Trim(), (IFormatProvider)(object)LanguageManager.Culture);220 }221 }222 catch (System.Exception exception)223 {224 ExceptionMgr.Instance.HandleException(exception, this);225 return;226 }227 using Transaction transaction = new Transaction(base.Session);228 IEntity entity = base.Session.Source().CreateNew("PersonWantsOrg");229 entity.PutValue("UID_PersonInserted", base.Session.User().Uid);230 entity.PutValue("UID_PersonOrdered", dbObject["UID_PersonSender"].NewValue);231 entity.PutValue("UID_Org", "QER-ITSHOPORG-DELEGATION-PR");232 entity.PutValue("ValidFrom", dateTime);233 entity.PutValue("ValidUntil", dateTime2);234 entity.PutValue("ObjectKeyAssignment", valueSafe.Replace(dbObject["UID_PersonSender"].New.String, dbObject["UID_PersonReceiver"].New.String));235 entity.Save(base.Session);236 dbObject["UID_PersonWantsOrg"].NewValue = entity.GetValue<string>("UID_PersonWantsOrg");237 transaction.Commit();238 }239240 private void TreeComboBoxDelegationDelegableElement_SelectedParentChanged(object sender, EventArgs e)241 {242 try243 {244 ISingleDbObject dbObject = m_MainActivator.DbObject;245 if (dbObject != null && m_TreeComboBoxDelegationDelegableElement.SelectedParent != null)246 {247 dbObject.SetValueSafe("ObjectKeyDelegated", m_TreeComboBoxDelegationDelegableElement.SelectedParent["ObjectKeyToDelegate"].NewValue);248 }249 }250 catch (System.Exception exception)251 {252 ExceptionMgr.Instance.HandleException(exception, this);253 }254 }255}256