作者:李坤凤
本次任务完成时间:2020年08月09日
开发工具与关键技术:开发工具:Visual Studio 关键技术:新建多条
新增代码
public void btnSuer()
{
try
{
if (Convert.ToInt32(cbotxtReceivingParty.SelectedValue) != 0 && Convert.ToInt32(cboMailSite.SelectedValue) != 0
&& Convert.ToInt32(cboRange.SelectedValue) != 0 && Convert.ToInt32(cboClearingForm.SelectedValue) != 0)
{
//新增
FreightBill SaFriegh = new FreightBill();
Customer SaFrieghBill = new Customer();
Staff SaStaff = new Staff();
SaFriegh.CustomerId = Convert.ToInt32(cboClient.SelectedValue);
SaFriegh.ReceivingPartyId = Convert.ToInt32(cbotxtReceivingParty.SelectedValue);
SaFriegh.StaffId = Convert.ToInt32(cboSolicitor.SelectedValue);
SaFriegh.SingleMan_StaffId = Convert.ToInt32(cboSingleMan.SelectedValue);
SaFriegh.Monograph_StaffId = Convert.ToInt32(cboMonograph.SelectedValue);
SaFriegh.CargoRangeId = Convert.ToInt32(cboRange.SelectedValue);
SaFriegh.MailSiteId = Convert.ToInt32(cboMailSite.SelectedValue);
SaFriegh.ReceivingBranchId = Convert.ToInt32(cboReceivingBranch.SelectedValue);
SaFriegh.RequestTime = DateTime.Now;
SaFriegh.SingleTime = DateTime.Now;
SaFriegh.DocumentNumber = txtOrderNumbers.Text.Trim();
SaFriegh.Remarks = txtRemark.Text.Trim();
SaFriegh.TotalFreight = Convert.ToDecimal(txtTotFreight.Text.Trim());
SaFriegh.LadingNunber = txtLadingNumber.Text.Trim();
SaFriegh.MailAddress = txtShippAddress.Text.Trim();
SaFriegh.ReceivingAddress = txtShippAddress.Text.Trim();
SaFriegh.FinalEstimateId = Convert.ToInt32(cboClearingForm.SelectedValue);
SaFrieghBill.Contact = txtPersonContacts.Text.Trim();
SaFrieghBill.ContactTelephone = txtContactTelephones.Text.Trim();
SaFrieghBill.Contact = txtContacts.Text.Trim();
SaFrieghBill.ContactTelephone = txtTelephones.Text.Trim();
myModel.FreightBill.Add(SaFriegh);
myModel.Customer.Add(SaFrieghBill);
myModel.Staff.Add(SaStaff);
Commodityvs myCommodityvs = dgCommodity.SelectedItem as Commodityvs;
for (int i = 0; i < dgCommodity.Items.Count; i++)
{
FreightDetails my = new FreightDetails();
Commodity mye = new Commodity();
CommodityTier Com = new CommodityTier();
BillingFormula Bill = new BillingFormula();
my.CommodityId = Convert.ToInt32(myCommodityvs.CommodityId);
mye.CommodityName = (myCommodityvs.CommodityName);
mye.CommodityTierId = Convert.ToInt32(myCommodityvs.CommodityTierId);
Com.CommodityType = (myCommodityvs.CommodityType);
my.Number = (myCommodityvs.Number);
mye.Prickle = (myCommodityvs.Prickle);
my.FreightPrice = (myCommodityvs.FreightPrice);
my.BillingFormulaId = Convert.ToInt32(myCommodityvs.BillingFormulaId);
Bill.BillingFort = (myCommodityvs.BillingFort);
my.IsRange = (myCommodityvs.IsRange);
myModel.FreightDetails.Add(my);
myModel.Commodity.Add(mye);
myModel.CommodityTier.Add(Com);
myModel.BillingFormula.Add(Bill);
}
//根据DocumentNumber 和LadingNunber
if (myModel.SaveChanges() > 0)
{
EmptyControls();
MessageBox.Show("新增成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
MessageBox.Show("新增失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
else
{
MessageBox.Show("请把数据填写完整!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
catch (Exception)
{
MessageBox.Show("操作失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
功能效果图: