|
|
|
|
using DevComponents.DotNetBar.Controls;
|
|
|
|
|
using POS.Language.Language;
|
|
|
|
|
using POSV.Entity;
|
|
|
|
|
using POSV.Utils;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace POSV.Shift
|
|
|
|
|
{
|
|
|
|
|
public partial class StoreCostForm : BusinessForm
|
|
|
|
|
{
|
|
|
|
|
private List<Feeitem> feeitemList = new List<Feeitem>();
|
|
|
|
|
private string itemName = null;
|
|
|
|
|
public StoreCostForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
|
|
|
|
|
if (this.DesignMode) return;
|
|
|
|
|
this.Focus();
|
|
|
|
|
this.moneyTextBox.Focus();
|
|
|
|
|
this.moneyTextBox.SelectAll();
|
|
|
|
|
this.ActiveControl = this.moneyTextBox;
|
|
|
|
|
this.inputDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
this.controlBox1.Text =LangProxy.ToLang( "非营业支出");
|
|
|
|
|
this.controlBox1.ShowApplicationVersion = false;
|
|
|
|
|
//填充项目支出
|
|
|
|
|
InitFeeitem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitFeeitem()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var db = Global.Instance.OpenDataBase)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sqlBuf = new StringBuilder();
|
|
|
|
|
sqlBuf.Append(" select * from pos_feeitem where type =1 and enabled =1 order by orderNo;");
|
|
|
|
|
feeitemList.AddRange(db.Fetch<Feeitem>(sqlBuf.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOGGER.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
if (feeitemList!=null && feeitemList.Count >0) {
|
|
|
|
|
itemName = feeitemList[0].Name;
|
|
|
|
|
}
|
|
|
|
|
this.feeitemCheckBox.DisplayMember = "name";
|
|
|
|
|
this.feeitemCheckBox.ValueMember = "id";
|
|
|
|
|
this.feeitemCheckBox.DataSource = feeitemList;
|
|
|
|
|
this.feeitemCheckBox.SelectedIndexChanged += OnFeeitemSelectedIndexChanged;
|
|
|
|
|
}
|
|
|
|
|
private void OnFeeitemSelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var obj = sender as ComboBoxEx;
|
|
|
|
|
string id = StringUtils.GetString(obj.SelectedValue);
|
|
|
|
|
Feeitem feeitem = feeitemList.Find(x => x.Id.Equals(id));
|
|
|
|
|
itemName = feeitem.Name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_exit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//先关闭父窗体
|
|
|
|
|
if (this.Owner != null)
|
|
|
|
|
{
|
|
|
|
|
this.Owner.Close();
|
|
|
|
|
}
|
|
|
|
|
//再关闭当前窗体
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCloseTouchClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//先关闭父窗体
|
|
|
|
|
if (this.Owner != null)
|
|
|
|
|
{
|
|
|
|
|
this.Owner.Close();
|
|
|
|
|
}
|
|
|
|
|
//再关闭当前窗体
|
|
|
|
|
this.Close();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnControlBoxKeyboardClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
NumericKeyboard.ShowKeyboard(this, this.moneyTextBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_ok_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (InputVerify()) {
|
|
|
|
|
//校验成功保存数据
|
|
|
|
|
string money = this.moneyTextBox.Text;
|
|
|
|
|
string description = itemName;
|
|
|
|
|
string memo = this.memoTextBox.Text;
|
|
|
|
|
StoreCostRevenue entity = new StoreCostRevenue();
|
|
|
|
|
entity.TenantId = Global.Instance.BusinessPlanLog.TenantId;
|
|
|
|
|
entity.WorkId = Global.Instance.BusinessPlanLog.WorkerId;
|
|
|
|
|
entity.WorkNo = Global.Instance.BusinessPlanLog.WorkerNo;
|
|
|
|
|
entity.WorkName = Global.Instance.BusinessPlanLog.WorkerName;
|
|
|
|
|
entity.ShiftName = Global.Instance.BusinessPlanLog.Name;
|
|
|
|
|
entity.ShiftNo = Global.Instance.BusinessPlanLog.No;
|
|
|
|
|
entity.StoreId = Global.Instance.BusinessPlanLog.StoreId;
|
|
|
|
|
entity.StoreNo = Global.Instance.BusinessPlanLog.StoreNo;
|
|
|
|
|
entity.StoreName = Global.Instance.Authc.StoreName;
|
|
|
|
|
entity.Name ="非营业支出";
|
|
|
|
|
entity.Money =Convert.ToDecimal(money);
|
|
|
|
|
entity.Type =1;
|
|
|
|
|
entity.Description = description;
|
|
|
|
|
entity.Memo = memo;
|
|
|
|
|
entity.InputDate = DateTime.Parse(this.inputDate.Text);
|
|
|
|
|
entity.PosNo = Global.Instance.Authc.PosNo;
|
|
|
|
|
entity.DeviceIp = DeviceUtils.Instance.IPAddress;
|
|
|
|
|
entity.DeviceMac = DeviceUtils.Instance.MacAddress;
|
|
|
|
|
entity.DeviceName = DeviceUtils.Instance.ComputerName;
|
|
|
|
|
saveStoreCost(entity);
|
|
|
|
|
this.moneyTextBox.Text = "";
|
|
|
|
|
this.memoTextBox.Text = "";
|
|
|
|
|
this.moneyTextBox.Focus();
|
|
|
|
|
ShowMessage(this.lblInfo, "保存成功", false);
|
|
|
|
|
var uploadObject = new UploadStoreCostRevenueObject();
|
|
|
|
|
uploadObject.Id = IdWorkerUtils.Instance.NextId();
|
|
|
|
|
uploadObject.TenantId = entity.TenantId;
|
|
|
|
|
uploadObject.SyncStatus = 0;
|
|
|
|
|
uploadObject.StoreCostRevenue = entity;
|
|
|
|
|
uploadObject.UploadErrors = 0;
|
|
|
|
|
saveStoreCostRevenueObject(uploadObject);
|
|
|
|
|
//有要上传的数据
|
|
|
|
|
LOGGER.Info("有需要上传的非营业数据,isHaveUpLoadFyy=true");
|
|
|
|
|
Global.isHaveUpLoadFyy = true;
|
|
|
|
|
|
|
|
|
|
var dialog = new DialogForm(LangProxy.ToLang("操作提醒"), LangProxy.ToLang("非营业支出保存成功"), MessageBoxIcon.Warning, MessageBoxButtons.OK);
|
|
|
|
|
dialog.ShowDialog();
|
|
|
|
|
//先关闭父窗体
|
|
|
|
|
if (this.Owner != null)
|
|
|
|
|
{
|
|
|
|
|
this.Owner.Close();
|
|
|
|
|
}
|
|
|
|
|
//再关闭当前窗体
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveStoreCost(StoreCostRevenue entity)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lock (Global.Instance.SyncLock)
|
|
|
|
|
{
|
|
|
|
|
using (var db = Global.Instance.OpenDataBase)
|
|
|
|
|
{
|
|
|
|
|
using (var transaction = db.GetTransaction())
|
|
|
|
|
{
|
|
|
|
|
db.Save<StoreCostRevenue>(entity);
|
|
|
|
|
transaction.Complete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOGGER.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveStoreCostRevenueObject(UploadStoreCostRevenueObject entity)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lock (Global.Instance.SyncLock)
|
|
|
|
|
{
|
|
|
|
|
using (var db = Global.Instance.OpenDataBase)
|
|
|
|
|
{
|
|
|
|
|
using (var transaction = db.GetTransaction())
|
|
|
|
|
{
|
|
|
|
|
// 保存要上传的数据
|
|
|
|
|
db.Save<UploadStoreCostRevenueObject>(entity);
|
|
|
|
|
transaction.Complete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOGGER.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool InputVerify()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(this.moneyTextBox.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ShowMessage(this.lblInfo, LangProxy.ToLang("请输入支出金额"), true);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(itemName.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ShowMessage(this.lblInfo, LangProxy.ToLang("请选择支出项目"), true);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|