This commit is contained in:
294
source/Plugins/AyaNovaOL/MapPhoneAddress.cs
Normal file
294
source/Plugins/AyaNovaOL/MapPhoneAddress.cs
Normal file
@@ -0,0 +1,294 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using Outlook = Microsoft.Office.Interop.Outlook;
|
||||
using Office = Microsoft.Office.Core;
|
||||
|
||||
namespace AyaNovaOL
|
||||
{
|
||||
public partial class MapPhoneAddress : Form
|
||||
{
|
||||
public MapPhoneAddress()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MapPhoneAddress_Load(object sender, EventArgs e)
|
||||
{
|
||||
Util.Localize(this);
|
||||
|
||||
cbOLToPhysical.DataSource = Enum.GetValues(typeof(AYOLAddressType));
|
||||
cbOLToPostal.DataSource = Enum.GetValues(typeof(AYOLAddressType));
|
||||
|
||||
cbPhone1.DataSource = Enum.GetValues(typeof(AYOLPhoneNumberType));
|
||||
cbPhone2.DataSource = Enum.GetValues(typeof(AYOLPhoneNumberType));
|
||||
cbPhone3.DataSource = Enum.GetValues(typeof(AYOLPhoneNumberType));
|
||||
cbPhone4.DataSource = Enum.GetValues(typeof(AYOLPhoneNumberType));
|
||||
cbPhone5.DataSource = Enum.GetValues(typeof(AYOLPhoneNumberType));
|
||||
|
||||
LoadSettings(false, RootObjectTypes.Client);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radClient.Checked)
|
||||
SaveSettings(RootObjectTypes.Client);
|
||||
else if (radHeadOffice.Checked)
|
||||
SaveSettings(RootObjectTypes.HeadOffice);
|
||||
else if (radVendor.Checked)
|
||||
SaveSettings(RootObjectTypes.Vendor);
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void radClient_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (radClient.Checked)
|
||||
LoadSettings(true, RootObjectTypes.Client);
|
||||
else
|
||||
SaveSettings(RootObjectTypes.Client);
|
||||
//If checked is false that means it was checked before so save
|
||||
|
||||
//if checked is true that means it was switched to and load
|
||||
|
||||
// AdjustDisplay();
|
||||
|
||||
}
|
||||
|
||||
private void radHeadOffice_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (radHeadOffice.Checked)
|
||||
LoadSettings(true, RootObjectTypes.HeadOffice);
|
||||
else
|
||||
SaveSettings(RootObjectTypes.HeadOffice);
|
||||
}
|
||||
|
||||
private void radVendor_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (radVendor.Checked)
|
||||
LoadSettings(true, RootObjectTypes.Vendor);
|
||||
else
|
||||
SaveSettings(RootObjectTypes.Vendor);
|
||||
}
|
||||
|
||||
private void AdjustDisplay()
|
||||
{
|
||||
if (radClient.Checked)
|
||||
{
|
||||
lblPhone1.Text = Util.LocaleText.GetLocalizedText("Client.Label.Phone1");
|
||||
lblPhone2.Text = Util.LocaleText.GetLocalizedText("Client.Label.Phone2");
|
||||
lblPhone3.Text = Util.LocaleText.GetLocalizedText("Client.Label.Phone3");
|
||||
lblPhone4.Text = Util.LocaleText.GetLocalizedText("Client.Label.Phone4");
|
||||
lblPhone5.Text = Util.LocaleText.GetLocalizedText("Client.Label.Phone5");
|
||||
}
|
||||
|
||||
if (radHeadOffice.Checked)
|
||||
{
|
||||
|
||||
lblPhone1.Text = Util.LocaleText.GetLocalizedText("HeadOffice.Label.Phone1");
|
||||
lblPhone2.Text = Util.LocaleText.GetLocalizedText("HeadOffice.Label.Phone2");
|
||||
lblPhone3.Text = Util.LocaleText.GetLocalizedText("HeadOffice.Label.Phone3");
|
||||
lblPhone4.Text = Util.LocaleText.GetLocalizedText("HeadOffice.Label.Phone4");
|
||||
lblPhone5.Text = Util.LocaleText.GetLocalizedText("HeadOffice.Label.Phone5");
|
||||
}
|
||||
|
||||
if (radVendor.Checked)
|
||||
{
|
||||
|
||||
lblPhone1.Text = Util.LocaleText.GetLocalizedText("Vendor.Label.Phone1");
|
||||
lblPhone2.Text = Util.LocaleText.GetLocalizedText("Vendor.Label.Phone2");
|
||||
lblPhone3.Text = Util.LocaleText.GetLocalizedText("Vendor.Label.Phone3");
|
||||
lblPhone4.Text = Util.LocaleText.GetLocalizedText("Vendor.Label.Phone4");
|
||||
lblPhone5.Text = Util.LocaleText.GetLocalizedText("Vendor.Label.Phone5");
|
||||
}
|
||||
|
||||
|
||||
//Util.d("AdjustDisplay bottom");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void LoadSettings(bool bPhoneOnly, RootObjectTypes oltype)
|
||||
{
|
||||
//Util.d("LoadSettings top phone only="+bPhoneOnly.ToString() + " oltype="+oltype.ToString());
|
||||
|
||||
if (!bPhoneOnly)
|
||||
{
|
||||
|
||||
cbSelectAddress(cbOLToPhysical, AyaNovaOL.Properties.Settings.Default.PhysicalAddressEquals);
|
||||
cbSelectAddress(cbOLToPostal, AyaNovaOL.Properties.Settings.Default.PostalAddressEquals);
|
||||
|
||||
switch ((RootObjectTypes)AyaNovaOL.Properties.Settings.Default.RootObjectType)
|
||||
{
|
||||
case RootObjectTypes.Client:
|
||||
radClient.Checked = true;
|
||||
break;
|
||||
case RootObjectTypes.HeadOffice:
|
||||
radHeadOffice.Checked = true;
|
||||
break;
|
||||
case RootObjectTypes.Vendor:
|
||||
radVendor.Checked = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
ckIgnoreThisIsTheMailingAddress.Checked = AyaNovaOL.Properties.Settings.Default.IgnoreThisIsTheMailingAddress;
|
||||
|
||||
}
|
||||
|
||||
switch (oltype)
|
||||
{
|
||||
//phone
|
||||
case RootObjectTypes.Client:
|
||||
{
|
||||
//Util.d("LoadSettings - SetClientPhone1:" + ((AYOLPhoneNumberType)AyaNovaOL.Properties.Settings.Default.ClientPhone1).ToString());
|
||||
cbSelectPhone(cbPhone1, AyaNovaOL.Properties.Settings.Default.ClientPhone1);
|
||||
cbSelectPhone(cbPhone2, AyaNovaOL.Properties.Settings.Default.ClientPhone2);
|
||||
cbSelectPhone(cbPhone3, AyaNovaOL.Properties.Settings.Default.ClientPhone3);
|
||||
cbSelectPhone(cbPhone4, AyaNovaOL.Properties.Settings.Default.ClientPhone4);
|
||||
cbSelectPhone(cbPhone5, AyaNovaOL.Properties.Settings.Default.ClientPhone5);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case RootObjectTypes.HeadOffice:
|
||||
{
|
||||
//Util.d("LoadSettings - SetHeadOfficePhone1:" + ((AYOLPhoneNumberType)AyaNovaOL.Properties.Settings.Default.HeadOfficePhone1).ToString());
|
||||
cbSelectPhone(cbPhone1, AyaNovaOL.Properties.Settings.Default.HeadOfficePhone1);
|
||||
cbSelectPhone(cbPhone2, AyaNovaOL.Properties.Settings.Default.HeadOfficePhone2);
|
||||
cbSelectPhone(cbPhone3, AyaNovaOL.Properties.Settings.Default.HeadOfficePhone3);
|
||||
cbSelectPhone(cbPhone4, AyaNovaOL.Properties.Settings.Default.HeadOfficePhone4);
|
||||
cbSelectPhone(cbPhone5, AyaNovaOL.Properties.Settings.Default.HeadOfficePhone5);
|
||||
}
|
||||
break;
|
||||
|
||||
case RootObjectTypes.Vendor:
|
||||
{
|
||||
//Util.d("LoadSettings - SetVendorPhone1:" + ((AYOLPhoneNumberType)AyaNovaOL.Properties.Settings.Default.VendorPhone1).ToString());
|
||||
cbSelectPhone(cbPhone1, AyaNovaOL.Properties.Settings.Default.VendorPhone1);
|
||||
cbSelectPhone(cbPhone2, AyaNovaOL.Properties.Settings.Default.VendorPhone2);
|
||||
cbSelectPhone(cbPhone3, AyaNovaOL.Properties.Settings.Default.VendorPhone3);
|
||||
cbSelectPhone(cbPhone4, AyaNovaOL.Properties.Settings.Default.VendorPhone4);
|
||||
cbSelectPhone(cbPhone5, AyaNovaOL.Properties.Settings.Default.VendorPhone5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
AdjustDisplay();
|
||||
//Util.d("LoadSettings bottom");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save selected settings
|
||||
/// </summary>
|
||||
/// <param name="obtype"></param>
|
||||
private void SaveSettings(RootObjectTypes obtype)
|
||||
{
|
||||
//Util.d("SaveSettings top");
|
||||
|
||||
switch (obtype)
|
||||
{
|
||||
case RootObjectTypes.Client:
|
||||
{
|
||||
//Util.d("SaveSettings - GetClientPhone1:" + ((AYOLPhoneNumberType)cbPhone1.SelectedItem.DataValue).ToString());
|
||||
AyaNovaOL.Properties.Settings.Default.ClientPhone1 = (int)(AYOLPhoneNumberType)cbPhone1.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.ClientPhone2 = (int)(AYOLPhoneNumberType)cbPhone2.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.ClientPhone3 = (int)(AYOLPhoneNumberType)cbPhone3.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.ClientPhone4 = (int)(AYOLPhoneNumberType)cbPhone4.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.ClientPhone5 = (int)(AYOLPhoneNumberType)cbPhone5.SelectedItem.DataValue;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case RootObjectTypes.HeadOffice:
|
||||
{
|
||||
//Util.d("SaveSettings - GetHeadOfficePhone1:" + ((AYOLPhoneNumberType)cbPhone1.SelectedItem.DataValue).ToString());
|
||||
AyaNovaOL.Properties.Settings.Default.HeadOfficePhone1 = (int)(AYOLPhoneNumberType)cbPhone1.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.HeadOfficePhone2 = (int)(AYOLPhoneNumberType)cbPhone2.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.HeadOfficePhone3 = (int)(AYOLPhoneNumberType)cbPhone3.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.HeadOfficePhone4 = (int)(AYOLPhoneNumberType)cbPhone4.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.HeadOfficePhone5 = (int)(AYOLPhoneNumberType)cbPhone5.SelectedItem.DataValue;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case RootObjectTypes.Vendor:
|
||||
{
|
||||
//Util.d("SaveSettings - GetVendorPhone1:" + ((AYOLPhoneNumberType)cbPhone1.SelectedItem.DataValue).ToString());
|
||||
AyaNovaOL.Properties.Settings.Default.VendorPhone1 = (int)(AYOLPhoneNumberType)cbPhone1.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.VendorPhone2 = (int)(AYOLPhoneNumberType)cbPhone2.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.VendorPhone3 = (int)(AYOLPhoneNumberType)cbPhone3.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.VendorPhone4 = (int)(AYOLPhoneNumberType)cbPhone4.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.VendorPhone5 = (int)(AYOLPhoneNumberType)cbPhone5.SelectedItem.DataValue;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
AyaNovaOL.Properties.Settings.Default.PhysicalAddressEquals = (int)(AYOLAddressType)cbOLToPhysical.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.PostalAddressEquals = (int)(AYOLAddressType)cbOLToPostal.SelectedItem.DataValue;
|
||||
AyaNovaOL.Properties.Settings.Default.IgnoreThisIsTheMailingAddress = ckIgnoreThisIsTheMailingAddress.Checked;
|
||||
AyaNovaOL.Properties.Settings.Default.FieldsMapped = true;
|
||||
AyaNovaOL.Properties.Settings.Default.Save();
|
||||
//Util.d("SaveSettings bottom");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void cbSelectPhone(GZTW.WinForm.Controls.GZUltraComboEditor cb, int phtype)
|
||||
{
|
||||
foreach (Infragistics.Win.ValueListItem vi in cb.Items)
|
||||
{
|
||||
if ((AYOLPhoneNumberType)vi.DataValue == (AYOLPhoneNumberType)phtype)
|
||||
{
|
||||
cb.SelectedItem = vi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cbSelectAddress(GZTW.WinForm.Controls.GZUltraComboEditor cb, int adrtype)
|
||||
{
|
||||
foreach (Infragistics.Win.ValueListItem vi in cb.Items)
|
||||
{
|
||||
if ((AYOLAddressType)vi.DataValue == (AYOLAddressType)adrtype)
|
||||
{
|
||||
cb.SelectedItem = vi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user