Files
ayanova7/source/WinFormApp/FollowUpSelector.cs
2018-06-29 19:47:36 +00:00

274 lines
9.8 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using GZTW.AyaNova.BLL;
using Infragistics.Win;
using log4net;
namespace AyaNova
{
/// <summary>
/// Summary description for FollowUpSelector.
/// </summary>
public class FollowUpSelector : System.Windows.Forms.Form
{
// Create a logger for use in this class
//case 1039 private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private System.Windows.Forms.Panel FollowUpSelector_Fill_Panel;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private GZTW.WinForm.Controls.GZUltraComboEditor cbScheduleMarkerID;
private System.Windows.Forms.Button btnNew;
//private System.ComponentModel.IContainer components;
public FollowUpSelector(Guid id, RootObjectTypes rotype)
{
InitializeComponent();
mobjectType = rotype;
mrootObjectID = id ;
}
public FollowUpSelector(TypeAndID tid)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
mobjectType = tid.RootObjectType;
mrootObjectID = tid.ID;
//
//
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
// if(components != null)
// {
// components.Dispose();
// }
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.FollowUpSelector_Fill_Panel = new System.Windows.Forms.Panel();
this.cbScheduleMarkerID = new GZTW.WinForm.Controls.GZUltraComboEditor();
this.btnNew = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.FollowUpSelector_Fill_Panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cbScheduleMarkerID)).BeginInit();
this.SuspendLayout();
//
// FollowUpSelector_Fill_Panel
//
this.FollowUpSelector_Fill_Panel.Controls.Add(this.cbScheduleMarkerID);
this.FollowUpSelector_Fill_Panel.Controls.Add(this.btnNew);
this.FollowUpSelector_Fill_Panel.Controls.Add(this.btnCancel);
this.FollowUpSelector_Fill_Panel.Controls.Add(this.btnOK);
this.FollowUpSelector_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
this.FollowUpSelector_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
this.FollowUpSelector_Fill_Panel.Location = new System.Drawing.Point(0, 0);
this.FollowUpSelector_Fill_Panel.Name = "FollowUpSelector_Fill_Panel";
this.FollowUpSelector_Fill_Panel.Size = new System.Drawing.Size(429, 111);
this.FollowUpSelector_Fill_Panel.TabIndex = 0;
//
// cbScheduleMarkerID
//
this.cbScheduleMarkerID.AllowEmptySelection = false;
this.cbScheduleMarkerID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbScheduleMarkerID.CausesValidation = false;
this.cbScheduleMarkerID.LimitToList = true;
this.cbScheduleMarkerID.Location = new System.Drawing.Point(10, 14);
this.cbScheduleMarkerID.Name = "cbScheduleMarkerID";
this.cbScheduleMarkerID.Size = new System.Drawing.Size(413, 24);
this.cbScheduleMarkerID.TabIndex = 30;
//
// btnNew
//
this.btnNew.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnNew.Image = global::AyaNova.Resource1.New24;
this.btnNew.Location = new System.Drawing.Point(163, 57);
this.btnNew.Name = "btnNew";
this.btnNew.Size = new System.Drawing.Size(90, 45);
this.btnNew.TabIndex = 29;
this.btnNew.Click += new System.EventHandler(this.btnNew_Click);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnCancel.Image = global::AyaNova.Resource1.Cancel24;
this.btnCancel.Location = new System.Drawing.Point(10, 57);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(90, 45);
this.btnCancel.TabIndex = 28;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnOK.Image = global::AyaNova.Resource1.OK24;
this.btnOK.Location = new System.Drawing.Point(327, 57);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(90, 45);
this.btnOK.TabIndex = 27;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// FollowUpSelector
//
this.AcceptButton = this.btnCancel;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(429, 111);
this.Controls.Add(this.FollowUpSelector_Fill_Panel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FollowUpSelector";
this.ShowInTaskbar = false;
this.Text = "LT:ScheduleMarker.Label.FollowUp";
this.Closing += new System.ComponentModel.CancelEventHandler(this.FollowUpSelector_Closing);
this.Load += new System.EventHandler(this.FollowUpSelector_Load);
this.FollowUpSelector_Fill_Panel.ResumeLayout(false);
this.FollowUpSelector_Fill_Panel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.cbScheduleMarkerID)).EndInit();
this.ResumeLayout(false);
}
#endregion
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
//
#region Global vars / Properties
private Guid mrootObjectID=Guid.Empty;
private RootObjectTypes mobjectType = RootObjectTypes.Nothing;
#endregion
#region Load / close events
private void FollowUpSelector_Load(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("FollowUpSelector_Load");
Util.Localize(this);
LoadCombo();
btnNew.Visible = AyaBizUtils.Right("Object.ScheduleMarker") > (int)SecurityLevelTypes.ReadOnly;
}
private void FollowUpSelector_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//case 1039 //log.Debug("FollowUpSelector_Closing");
}
#endregion
#region Combo box intialization / events
private void LoadCombo()
{
//case 1039 //log.Debug("LoadCombo");
cbScheduleMarkerID.Items.Clear();
FollowUpPickList UList = FollowUpPickList.GetList(mrootObjectID);
foreach (FollowUpPickList.FollowUpPickListInfo ui in UList)
{
cbScheduleMarkerID.Items.Add(ui.ID, ui.Name);
}
cbScheduleMarkerID.SelectedIndex = 0;
}
#endregion
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
if (cbScheduleMarkerID.SelectedItem == null) return;
ScheduleMarker sm = ScheduleMarker.GetItem((Guid)cbScheduleMarkerID.SelectedItem.DataValue);
ShowScheduleMarkerForm(sm);
}
private void btnNew_Click(object sender, EventArgs e)
{
ScheduleMarker sm = ScheduleMarker.NewItem();
sm.FollowID = mrootObjectID;
sm.FollowType = mobjectType;
sm.ScheduleMarkerSourceType = ScheduleMarkerSourceTypes.User;
sm.SourceID = User.CurrentThreadUserID;
sm.StartDate = DBUtil.CurrentWorkingDateTime;
sm.StopDate = DBUtil.CurrentWorkingDateTime.AddHours(1);
ShowScheduleMarkerForm(sm);
}
private void ShowScheduleMarkerForm(ScheduleMarker sm)
{
ScheduleMarkerForm f = new ScheduleMarkerForm();
f.bHideFollowObjectButton = true;
f.ScheduleMarkerToEdit = sm;
f.ShowDialog();
if (f.ChangesMade)
LoadCombo();
f.Dispose();
}
//--------------------------------------------------------
}
}