コード例 #1
0
        public ActionResult Create(FormCollection formColl)
        {
            try
            {
                if (!string.IsNullOrEmpty(formColl["loginid"]))
                {
                    ViewBag.LoginID = formColl["loginid"];
                }
                else
                {
                    ViewBag.LoginID = "";
                }
                if (!string.IsNullOrEmpty(formColl["type"]))
                {
                    ViewBag.Type = formColl["type"];
                }
                else
                {
                    ViewBag.Type = "";
                }

                DateTime dt = DateTime.Parse(formColl["ApplyDate"]);
                #region 添加发票数据
                Outsourcing.EF.InvoiceApplication model = new Outsourcing.EF.InvoiceApplication();
                model.ID                   = Guid.NewGuid().ToString();
                model.OutrCompanyID        = int.Parse(formColl["CompanyID"]);
                model.CustomerCompanyID    = Convert.ToInt32(Session["ID"]);
                model.SettlementMoney      = double.Parse(formColl["Moneys"]);
                model.SettlementYear       = dt.Year;
                model.SettlementMonth      = dt.Month;
                model.InvoiceOutState      = 1; //未开具
                model.InvoiceCustomerState = 0; // 0已申请;1已开具
                model.OperationTime        = DateTime.Now;

                if (invoiceApp.Insert(model) == 1)
                {
                    #region 添加发票购买方信息
                    Outsourcing.EF.InvoiceDetail detail = new Outsourcing.EF.InvoiceDetail();
                    detail.InvoiceID           = model.ID;
                    detail.InvoiceMoney        = (decimal)model.SettlementMoney;
                    detail.BuyerName           = formColl["CompanyName"];
                    detail.BuyerAddress        = formColl["Address"];
                    detail.BuyerTel            = formColl["Tel"];
                    detail.BuyerTaxpayerNumber = formColl["TaxpayerNumber"];
                    detail.BuyerBankDeposit    = formColl["BankDeposit"];
                    detail.BuyerBankAccount    = formColl["BankAccount"];
                    invoiceDetailDAL.Insert(detail);
                    #endregion
                }
                #endregion

                return(Content("loginid=" + ViewBag.LoginID + "&&type=" + ViewBag.Type));
            }
            catch
            {
                return(Content("失败"));
            }
        }
コード例 #2
0
        public ActionResult EditInvoiceDetail(FormCollection formColl)
        {
            try
            {
                if (!string.IsNullOrEmpty(formColl["loginid"]))
                {
                    ViewBag.LoginID = formColl["loginid"];
                }
                else
                {
                    ViewBag.LoginID = "";
                }
                if (!string.IsNullOrEmpty(formColl["type"]))
                {
                    ViewBag.Type = formColl["type"];
                }
                else
                {
                    ViewBag.Type = "";
                }


                #region 编辑销售方发票数据
                Outsourcing.EF.InvoiceApplication model = invoiceApp.GetModel(formColl["ID"]);
                model.InvoiceOutState = 0;   //1未开具   0已开具
                if (invoiceApp.Update(model) == 1)
                {
                    #region 添加发票购买方信息
                    Outsourcing.EF.InvoiceDetail detail = invoiceDetailDAL.GetModel(model.ID);
                    if (detail != null)
                    {
                        detail.InvoiceType = int.Parse(formColl["InvoiceType"]);
                        detail.InvoiceName = formColl["InvoiceName"];
                        detail.InvoiceCode = formColl["InvoiceCode"];

                        detail.SalesName           = formColl["CompanyName"];
                        detail.SalesAddress        = formColl["Address"];
                        detail.SalesTel            = formColl["Tel"];
                        detail.SalesTaxpayerNumber = formColl["TaxpayerNumber"];
                        detail.SalesBankDeposit    = formColl["BankDeposit"];
                        detail.SalesBankAccount    = formColl["BankAccount"];
                        invoiceDetailDAL.Update(detail);
                    }
                    #endregion
                }
                #endregion
                return(Content("loginid=" + ViewBag.LoginID + "&&type=" + ViewBag.Type));
            }
            catch (Exception ex)
            {
                return(Content(""));
            }
        }