新建多条

作者:李坤凤
本次任务完成时间: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);
            }
        }



功能效果图:

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值