260 lines
10 KiB
C#
260 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Telerik.WinControls;
|
|
using Telerik.WinControls.UI;
|
|
using SafeMobileLib;
|
|
using System.Globalization;
|
|
using System.Media;
|
|
|
|
namespace SubscriberAndUserManager
|
|
{
|
|
public partial class TicketingForm : Telerik.WinControls.UI.RadForm
|
|
{
|
|
private DBTicketingManager DB;
|
|
private DBsettingsManager DBsettings;
|
|
private DBgatewaysManager DBgateway;
|
|
private string editStatusName = "";
|
|
private bool formTypeEdit = false; //false = add user mode; true = edit user mode
|
|
|
|
private void setLanguage()
|
|
{
|
|
this.Text = MainForm.returnLNGString("tsform");
|
|
lbName.Text = MainForm.returnLNGString("tsname");
|
|
lbColor.Text = MainForm.returnLNGString("tscolor");
|
|
lbCompletionStatus.Text = MainForm.returnLNGString("tscompstat");
|
|
lblDefault.Text = MainForm.returnLNGString("tsdefautstat");
|
|
btnExit.Text = MainForm.returnLNGString("exit");
|
|
btnAdd.Text = MainForm.returnLNGString("add");
|
|
}
|
|
|
|
public TicketingForm(DBTicketingManager DB, DBsettingsManager DBsettings, DBgatewaysManager DBgateway)
|
|
{
|
|
InitializeComponent();
|
|
setLanguage();
|
|
//cbUserType.SelectedIndex = 0;
|
|
this.DB = DB;
|
|
this.DBsettings = DBsettings;
|
|
this.DBgateway = DBgateway;
|
|
if (MainForm.radioType==RADIOTYPE.HYT)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.SYTADMIN24x;
|
|
this.BackColor = MainForm.HyteraColor;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.HARRIS)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.visionSmall;
|
|
this.BackColor = MainForm.HarrisColor;
|
|
foreach (Control x in this.Controls)
|
|
{
|
|
if (x is RadLabel)
|
|
{
|
|
((RadLabel)x).ForeColor = MainForm.HarTextColor;
|
|
}
|
|
}
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.SIMOCO)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.simoco_setup_241;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.EXCERA)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.AXYS_ICON;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.ATLAS)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.ATLASadmin32; //ATLASCHANGE
|
|
this.BackColor = MainForm.HarrisColor;
|
|
foreach (Control x in this.Controls)
|
|
{
|
|
if (x is RadLabel)
|
|
{
|
|
((RadLabel)x).ForeColor = MainForm.HarTextColor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public TicketingForm(DBTicketingManager DB, TicketingStatus ts)
|
|
{
|
|
//edit mode
|
|
InitializeComponent();
|
|
setLanguage();
|
|
this.DB = DB;
|
|
|
|
formTypeEdit = true;
|
|
btnAdd.Text = MainForm.returnLNGString("edit");
|
|
editStatusName = ts.Status;
|
|
txtName.Text = ts.Status;
|
|
int argb = Int32.Parse(ts.Color, NumberStyles.HexNumber);
|
|
txtColor.TextBoxElement.TextBoxItem.BackColor = Color.FromArgb(argb);
|
|
txtSound.Text = ts.SoundFile;
|
|
ckSound.Checked = (ts.SoundOn == 1);
|
|
ckDefault.Checked = (ts.IsFirstState == 1);
|
|
ckCompletionStatus.Checked = (ts.IsLastState == 1);
|
|
if (MainForm.radioType== RADIOTYPE.HYT)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.SYTADMIN24x;
|
|
this.BackColor = MainForm.HyteraColor;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.HARRIS)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.visionSmall;
|
|
this.BackColor = MainForm.HarrisColor;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.SIMOCO)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.simoco_setup_241;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.EXCERA)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.AXYS_ICON;
|
|
}
|
|
else if (MainForm.radioType == RADIOTYPE.ATLAS)
|
|
{
|
|
this.Icon = global::SubscriberAndUserManager.Properties.Resources.ATLASadmin32; //ATLASCHANGE
|
|
this.BackColor = MainForm.HarrisColor;
|
|
}
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
public bool OnlyHexInString(string test)
|
|
{
|
|
// For C-style hex notation (0xFF) you can use @"\A\b(0[xX])?[0-9a-fA-F]+\b\Z"
|
|
return System.Text.RegularExpressions.Regex.IsMatch(test, @"\A\b[0-9a-fA-F]+\b\Z");
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
TicketingStatus ts = new TicketingStatus();
|
|
TicketResponse resp = new TicketResponse();
|
|
if (ckCompletionStatus.Checked) resp = DB.resetCompletionStatus();
|
|
if (ckDefault.Checked) resp = DB.resetDefaultStatus();
|
|
ts.Status = txtName.Text;
|
|
if (OnlyHexInString(txtColor.TextBoxElement.TextBoxItem.BackColor.Name.ToString()))
|
|
ts.Color = txtColor.TextBoxElement.TextBoxItem.BackColor.Name.ToString();
|
|
else
|
|
{
|
|
int ColorValue = Color.FromName(txtColor.TextBoxElement.TextBoxItem.BackColor.Name.ToString()).ToArgb();
|
|
ts.Color = string.Format("{0:x6}", ColorValue);
|
|
}
|
|
ts.SoundOn = (ckSound.Checked) ? 1 : 0;
|
|
ts.SoundFile = txtSound.Text;
|
|
ts.IsFirstState = (ckDefault.Checked) ? 1 : 0;
|
|
ts.IsLastState = (ckCompletionStatus.Checked) ? 1 : 0;
|
|
if (!formTypeEdit) resp = DB.addTicketStatusToDb(ts);
|
|
else
|
|
{
|
|
ts.StatusID = DB.getStatusID(editStatusName);
|
|
resp = DB.updateTicketStatusToDb(ts);
|
|
}
|
|
HandleResp(resp);
|
|
}
|
|
|
|
//utils
|
|
|
|
public void HandleResp(TicketResponse resp)
|
|
{
|
|
switch (resp)
|
|
{
|
|
case TicketResponse.done:
|
|
if (!formTypeEdit)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.check, MainForm.returnLNGString("tsadd"), MainForm.returnLNGString("done"));
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.check, MainForm.returnLNGString("tsedit"), MainForm.returnLNGString("done"));
|
|
this.Close();
|
|
}
|
|
ClearTSInfo();
|
|
break;
|
|
case TicketResponse.alreadyInDB:
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("tsallin"), MainForm.returnLNGString("err"));
|
|
break;
|
|
case TicketResponse.SQLerror:
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("dberr"), MainForm.returnLNGString("err"));
|
|
break;
|
|
case TicketResponse.ticketNotInDB:
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("tsin"), MainForm.returnLNGString("err"));
|
|
break;
|
|
case TicketResponse.alreadyInTransactions:
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("tsallintrans"), MainForm.returnLNGString("err"));
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void ClearTSInfo()
|
|
{
|
|
foreach (Control x in this.Controls)
|
|
{
|
|
if (x is RadTextBox)
|
|
{
|
|
((RadTextBox)x).Text = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnChooseColor_Click(object sender, EventArgs e)
|
|
{
|
|
RadColorDialog radColorDialog1 = new RadColorDialog();
|
|
if (radColorDialog1.ShowDialog() == DialogResult.OK)
|
|
{
|
|
txtColor.TextBoxElement.TextBoxItem.BackColor = radColorDialog1.SelectedColor;
|
|
}
|
|
}
|
|
|
|
private void btnChooseSound_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
ofd.Title = "Sound File Selection";
|
|
ofd.Filter = "Sound files|*.wav";
|
|
ofd.ShowDialog();
|
|
txtSound.Text = ofd.FileName;
|
|
}
|
|
|
|
private void ckSound_CheckStateChanged(object sender, EventArgs e)
|
|
{
|
|
btnChooseSound.Enabled = btnPlay.Enabled = ckSound.Checked;
|
|
}
|
|
|
|
private void btnPlay_Click(object sender, EventArgs e)
|
|
{
|
|
if (txtSound.Text != null && txtSound.Text != "")
|
|
{
|
|
SoundPlayer simpleSound = new SoundPlayer(txtSound.Text);
|
|
simpleSound.PlaySync();
|
|
}
|
|
}
|
|
|
|
private void txtName_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (char.IsLetter(e.KeyChar) || char.IsWhiteSpace(e.KeyChar))
|
|
{ }
|
|
else
|
|
{
|
|
e.Handled = e.KeyChar != (char)Keys.Back;
|
|
}
|
|
}
|
|
|
|
private void ckCompletionStatus_CheckStateChanged(object sender, EventArgs e)
|
|
{
|
|
if (ckCompletionStatus.Checked && ckDefault.Checked) ckDefault.Checked = false;
|
|
}
|
|
|
|
private void ckDefault_CheckStateChanged(object sender, EventArgs e)
|
|
{
|
|
if (ckCompletionStatus.Checked && ckDefault.Checked) ckCompletionStatus.Checked = false;
|
|
}
|
|
}
|
|
}
|