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 { 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"); } #region IAfterLogin Member public string RoleName { get { return "_1"; } } public Form Generate() { return this; } #endregion 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) { } WeightBill _dmo = new WeightBill() { CreaterName = AppContext.Context.UserConfig.UserName }; WeightBill Dmo { get { return _dmo; } } void GetFromUI() { if (!supplierSelect.IsEmpty) { Dmo.Supplier_ID = long.Parse(supplierSelect.Value); Dmo.Supplier_Name = supplierSelect.DisplayValue; } if (!purchaseTypeSelect.IsEmpty) { Dmo.PurchaseType_ID = short.Parse(purchaseTypeSelect.Value); Dmo.PurchaseType_Name = purchaseTypeSelect.DisplayValue; } Dmo.WeightTime = weightTimeSelect.Date; if (!carSelect.IsEmpty) { Dmo.Car_ID = long.Parse(carSelect.Value); Dmo.Car_Name = carSelect.DisplayValue; } if (!liveVarietiesSelect.IsEmpty) { Dmo.Livestock_ID = long.Parse(liveVarietiesSelect.Value); Dmo.Livestock_Name = liveVarietiesSelect.DisplayValue; } if (!employeeSelect.IsEmpty) { Dmo.Employee_ID = long.Parse(employeeSelect.Value); Dmo.Employee_Name = employeeSelect.DisplayValue; } if (!hogGradeSelect.IsEmpty) { Dmo.HogGrade_ID = long.Parse(hogGradeSelect.Value); Dmo.HogGrade_Name = hogGradeSelect.DisplayValue; } if (!zoneSelect.IsEmpty) { Dmo.Zone_ID = long.Parse(zoneSelect.Value); Dmo.Zone_Name = zoneSelect.DisplayValue; } if (!string.IsNullOrEmpty(penWeightInput.Text)) { decimal pw = 0; if (!decimal.TryParse(penWeightInput.Text.Trim(), out pw)) throw new Exception("棚前重量输入错误"); Dmo.PenWeight = pw; } if (!string.IsNullOrEmpty(penPriceInput.Text)) { decimal pp = 0; if (!decimal.TryParse(penPriceInput.Text.Trim(), out pp)) throw new Exception("棚前单价输入错误"); Dmo.PenPrice = pp; } Dmo.PenMoney = Dmo.PenPrice * Dmo.PenWeight; 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() { if (Dmo.Supplier_ID.HasValue) supplierSelect.Fill(Dmo.Supplier_Name, Dmo.Supplier_ID.ToString()); if (Dmo.PurchaseType_ID.HasValue) purchaseTypeSelect.Fill(Dmo.PurchaseType_Name, Dmo.PurchaseType_ID.ToString()); weightTimeSelect.Date = Dmo.WeightTime.Value; Dmo.WeightTime = weightTimeSelect.Date; if (Dmo.Car_ID.HasValue) carSelect.Fill(Dmo.Car_Name, Dmo.Car_ID.ToString()); if (Dmo.Livestock_ID.HasValue) liveVarietiesSelect.Fill(Dmo.Livestock_Name, Dmo.Livestock_ID.ToString()); if (Dmo.Employee_ID.HasValue) employeeSelect.Fill(Dmo.Employee_Name, Dmo.Employee_ID.ToString()); if (Dmo.HogGrade_ID.HasValue) hogGradeSelect.Fill(Dmo.HogGrade_Name, Dmo.HogGrade_ID.ToString()); if (Dmo.Zone_ID.HasValue) zoneSelect.Fill(Dmo.Zone_Name, Dmo.Zone_ID.ToString()); if (Dmo.PenWeight.HasValue) penWeightInput.Text = Dmo.PenWeight.Value.ToString(); if (Dmo.PenPrice.HasValue) penPriceInput.Text = Dmo.PenPrice.Value.ToString(); if (Dmo.PenMoney.HasValue) penMoneyInput.Text = Dmo.PenMoney.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; } } }