2016-01-04 05:22:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Repository;
|
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
public partial class MachineEditForm : Form
|
|
|
|
|
{
|
|
|
|
|
private Guid? _machineLocationID;
|
|
|
|
|
private string _machineName;
|
|
|
|
|
public MachineEditForm(Guid machineLocationID)
|
|
|
|
|
: this()
|
|
|
|
|
{
|
|
|
|
|
_machineLocationID = machineLocationID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MachineEditForm(string machineName)
|
|
|
|
|
: this()
|
|
|
|
|
{
|
|
|
|
|
_machineName = machineName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MachineEditForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MachineEditForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MachineLocation machineLocation;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
bsLocations.DataSource = LocationBI.List();
|
|
|
|
|
if (_machineLocationID.HasValue)
|
2016-01-04 05:22:01 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
machineLocation = MachineLocationBI.Get(_machineLocationID.Value);
|
|
|
|
|
txtMachine.Text = machineLocation.Machine;
|
|
|
|
|
cmbLocation.SelectedItem = machineLocation.Location;
|
|
|
|
|
txtMachine.Focus();
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(_machineName))
|
|
|
|
|
{
|
|
|
|
|
txtMachine.Text = _machineName;
|
|
|
|
|
txtMachine.ReadOnly = true;
|
|
|
|
|
cmbLocation.Focus();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtMachine.Focus();
|
2016-01-04 05:22:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MachineLocation machineLocation;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
if (_machineLocationID.HasValue)
|
|
|
|
|
machineLocation = MachineLocationBI.Get(_machineLocationID.Value);
|
|
|
|
|
else
|
|
|
|
|
machineLocation = new MachineLocation();
|
2016-01-04 05:22:01 +00:00
|
|
|
|
|
2018-08-24 10:41:33 +00:00
|
|
|
|
if (string.IsNullOrEmpty(txtMachine.Text.Trim()))
|
|
|
|
|
return;
|
|
|
|
|
machineLocation.Machine = txtMachine.Text.Trim();
|
|
|
|
|
var location = (string)cmbLocation.SelectedItem;
|
|
|
|
|
if (string.IsNullOrEmpty(location))
|
|
|
|
|
return;
|
|
|
|
|
machineLocation.Location = location;
|
|
|
|
|
if (_machineLocationID.HasValue)
|
|
|
|
|
MachineLocationBI.Update(machineLocation);
|
|
|
|
|
else
|
|
|
|
|
MachineLocationBI.Insert(machineLocation);
|
2016-01-04 05:22:01 +00:00
|
|
|
|
MessageBox.Show("Update / Save Successful");
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|