屠宰场客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
6.5 KiB

using BO.BO;
using BO.Utils;
using BO.Utils.BillRpc;
using ButcherManageClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ButcherWeight
{
public partial class WeightForm : Form, IAfterLogin
{
#region IAfterLogin Member
public string RoleName
{
get { return "_1"; }
}
public Form Generate()
{
return this;
}
#endregion
public WeightForm()
{
InitializeComponent();
supplierSelect.Init("BaseInfoRpc/GetSupplierList");
purchaseTypeSelect.Init("BaseInfoRpc/GetPurchaseTypeList");
carSelect.Init("BaseInfoRpc/GetCarList");
liveVarietiesSelect.Init("BaseInfoRpc/GetLiveVarietiesList");
employeeSelect.Init("BaseInfoRpc/GetEmployeeList");
hogGradeSelect.Init("BaseInfoRpc/GetHogGradeList");
zoneSelect.Init("BaseInfoRpc/GetZoneList");
farmerSelect.Init("BaseInfoRpc/GetFarmerList");
farmerSelect.EnableTopItem = false;
weightTimeSelect.Date = DateTime.Now;
testTimeInput.Date = DateTime.Now;
dmoList = WeightBillRpc.GetWeightBillList();
}
private List<WeightBill> dmoList = new List<WeightBill>();
private WeightBill Dmo = new WeightBill();
private void exitBtn_Click(object sender, EventArgs e)
{
this.Close();
}
private void commitBtn_Click(object sender, EventArgs e)
{
GetFromUI();
var result = WeightBillRpc.Send(Dmo);
if (result)
MessageBox.Show("保存成功!");
}
private void readMaoBtn_Click(object sender, EventArgs e)
{
}
private void readPiBtn_Click(object sender, EventArgs e)
{
}
private void farmerSelect_SelectedIndexChanged(object sender, EventArgs e)
{
if (farmerSelect.IsEmpty)
return;
var detail = new WeightBill_FarmerDetail();
detail.Farmer_ID = farmerSelect.LongValue.Value;
if (Dmo.FarmerDetails.Any(x => x.Farmer_ID == detail.Farmer_ID))
return;
detail.Farmer_Name = farmerSelect.DisplayValue;
Dmo.FarmerDetails.Add(detail);
detail.Index = Dmo.FarmerDetails.Max(x => x.Index) + 1;
detail.WeightBill_ID = Dmo.ID;
farmerSelect.Clear();
}
void GetFromUI()
{
if (!employeeSelect.IsEmpty)
{
Dmo.Employee_ID = long.Parse(employeeSelect.Value);
Dmo.Employee_Name = employeeSelect.DisplayValue;
}
Dmo.WeighTime = weightTimeSelect.Date;
if (!supplierSelect.IsEmpty)
{
Dmo.Supplier_ID = long.Parse(supplierSelect.Value);
Dmo.Supplier_Name = supplierSelect.DisplayValue;
}
if (!zoneSelect.IsEmpty)
{
Dmo.Zone_ID = long.Parse(zoneSelect.Value);
Dmo.Zone_Name = zoneSelect.DisplayValue;
}
if (!purchaseTypeSelect.IsEmpty)
{
Dmo.PurchaseType_ID = short.Parse(purchaseTypeSelect.Value);
Dmo.PurchaseType_Name = purchaseTypeSelect.DisplayValue;
}
if (!carSelect.IsEmpty)
{
Dmo.Car_ID = long.Parse(carSelect.Value);
Dmo.Car_Name = carSelect.DisplayValue;
}
if (!liveVarietiesSelect.IsEmpty)
{
Dmo.LiveVarieties_ID = long.Parse(liveVarietiesSelect.Value);
Dmo.LiveVarieties_Name = liveVarietiesSelect.DisplayValue;
}
if (!hogGradeSelect.IsEmpty)
{
Dmo.HogGrade_ID = long.Parse(hogGradeSelect.Value);
Dmo.HogGrade_Name = hogGradeSelect.DisplayValue;
}
if (!string.IsNullOrEmpty(penWeightInput.Text))
{
decimal pw = 0;
if (!decimal.TryParse(penWeightInput.Text.Trim(), out pw))
throw new Exception("棚前重量输入错误");
Dmo.ShackWeight = pw;
}
if (!string.IsNullOrEmpty(penPriceInput.Text))
{
decimal pp = 0;
if (!decimal.TryParse(penPriceInput.Text.Trim(), out pp))
throw new Exception("棚前单价输入错误");
Dmo.ShackPrice = pp;
}
if (!string.IsNullOrEmpty(testCardNumberInput.Text))
Dmo.AnimalTestNumber = testCardNumberInput.Text;
if (!string.IsNullOrEmpty(testTimeInput.Text))
Dmo.AnimalTestDate = testTimeInput.Date;
if (!string.IsNullOrEmpty(testManInput.Text))
Dmo.AnimalTestMan = testManInput.Text;
if (!string.IsNullOrEmpty(remarkInput.Text))
Dmo.Remark = remarkInput.Text;
}
void AppToUI()
{
ResetControl();
if (Dmo.Employee_ID.HasValue)
employeeSelect.Fill(Dmo.Employee_Name, Dmo.Employee_ID.ToString());
if (Dmo.WeighTime.HasValue)
weightTimeSelect.Date = Dmo.WeighTime;
if (Dmo.Supplier_ID.HasValue)
supplierSelect.Fill(Dmo.Supplier_Name, Dmo.Supplier_ID.ToString());
if (Dmo.Zone_ID.HasValue)
zoneSelect.Fill(Dmo.Zone_Name, Dmo.Zone_ID.ToString());
if (Dmo.PurchaseType_ID.HasValue)
purchaseTypeSelect.Fill(Dmo.PurchaseType_Name, Dmo.PurchaseType_ID.ToString());
if (Dmo.Car_ID.HasValue)
carSelect.Fill(Dmo.Car_Name, Dmo.Car_ID.ToString());
if (Dmo.LiveVarieties_ID.HasValue)
liveVarietiesSelect.Fill(Dmo.LiveVarieties_Name, Dmo.LiveVarieties_ID.ToString());
if (Dmo.HogGrade_ID.HasValue)
hogGradeSelect.Fill(Dmo.HogGrade_Name, Dmo.HogGrade_ID.ToString());
if (Dmo.ShackWeight.HasValue)
penWeightInput.Text = Dmo.ShackWeight.Value.ToString();
if (Dmo.ShackPrice.HasValue)
penPriceInput.Text = Dmo.ShackPrice.Value.ToString();
if (Dmo.ShackMoney.HasValue)
penMoneyInput.Text = Dmo.ShackMoney.Value.ToString();
if (!string.IsNullOrEmpty(Dmo.AnimalTestNumber))
testCardNumberInput.Text = Dmo.AnimalTestNumber;
if (Dmo.AnimalTestDate.HasValue)
testTimeInput.Date = Dmo.AnimalTestDate.Value;
if (!string.IsNullOrEmpty(Dmo.AnimalTestMan))
testManInput.Text = Dmo.AnimalTestMan;
if (!string.IsNullOrEmpty(Dmo.Remark))
remarkInput.Text = Dmo.Remark;
}
void ResetControl()
{
employeeSelect.Clear();
weightTimeSelect.Date = null;
supplierSelect.Clear();
zoneSelect.Clear();
purchaseTypeSelect.Clear();
carSelect.Clear();
liveVarietiesSelect.Clear();
hogGradeSelect.Clear();
penWeightInput.Text = null;
penPriceInput.Text = null;
penMoneyInput.Text = null;
testCardNumberInput.Text = null;
testTimeInput.Date = null;
testManInput.Text = null;
remarkInput.Text = null;
}
}
}