Example #1
0
        public ActionResult RepealSubmit(Billing data)
        {
            int id = data.IDX;
            int BillingType = 0;
            int idx = Util.toint(Request.Form["data[IDX]"].Trim());
            TugDataEntities db = new TugDataEntities();
            System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == idx;
            Billing billInfor = db.Billing.Where(exp).FirstOrDefault();

            int Phase = Convert.ToInt32(billInfor.Phase);
            int timeNo = Convert.ToInt32(billInfor.TimesNo);
            int curUserId = Session.GetDataFromSession<int>("userid");
            if (Phase > 1 || Phase == -1)  //流程已进入审核环节或已完成全部审核,不能撤销
            {
                var ret = new { code = Resources.Common.ERROR_CODE, message = "流程已进入审核环节,不能撤销!" };
                return Json(ret);
            }
            else
            {
                //更新Billing状态
                billInfor.Phase = 0;
                billInfor.Status = "已撤销提交";
                db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                string billtype = billInfor.InvoiceType.ToString();
                if (billtype == "特殊账单") BillingType = 1;

                //修改訂單表
                FinanceLogic.SetOrderServiceFlowingStatus(BillingType, idx, "否");

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = idx;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = 0;
                addApprove.Task = "创建";
                addApprove.Accept = 3;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();
                return Json(new { message = "撤销成功!" });
            }
        }
Example #2
0
        public ActionResult AddDiscountBill(int customerId, string title, string content, double money, string month, string date, string billingCode)
        {
            this.Internationalization();
            try
            {
                TugDataEntities db = new TugDataEntities();
                {
                    //0.验证账单编号是否已存在
                    var tmp = db.Billing.FirstOrDefault(u => u.BillingCode.Trim() == billingCode.Trim());
                    if (tmp != null)
                    {
                        var ret2 = new { code = Resources.Common.FAIL_CODE, message = "其他賬單編號已存在!" };
                        //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                        return Json(ret2, JsonRequestBehavior.AllowGet);
                    }

                    TugDataModel.Billing credit = new TugDataModel.Billing();

                    credit.CustomerID = customerId;
                    //credit.CreditCode = "C" +  billingCode.Substring(1, billingCode.Length - 1 );
                    credit.UserDefinedCol1 = title;
                    credit.UserDefinedCol2 = content;
                    credit.UserDefinedCol5 = money;
                    credit.Amount = money;
                    credit.Month = month;
                    credit.UserDefinedCol10 = date;
                    credit.InvoiceType = "其他账单";
                    credit.CreateDate = credit.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    credit.OwnerID = -1;
                    credit.UserID = credit.UserID = Session.GetDataFromSession<int>("userid");
                    credit.BillingCode = billingCode.Trim();

                    credit.TimesNo = 0;
                    credit.Status = "创建";
                    credit.Phase = 0;

                    credit = db.Billing.Add(credit);
                    db.SaveChanges();

                }

                var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                return Json(ret, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {
                var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                return Json(ret, JsonRequestBehavior.AllowGet);
            }
        }
Example #3
0
        public ActionResult AddInvoice2(int custId, int custShipId, string orderIds, string orderServiceIds, int billingTemplateId, int billingTypeId, int timeTypeId,
            string jobNo, string billing_code, string remark, double discount, double amount, string month, string date, int customer_ship_length,
            int customer_ship_teus, string isShowShipLengthRule, string isShowShipTEUSRule,
            float? ratio1, float? ratio2, float? ratio3, float? ratio4, float? ratio5, float? ratio6, float? ratio7, float? minTime,
            string jsonArrayItems, string jsonArraySummaryItems)
        {
            this.Internationalization();

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {

                    List<string> strOrderIDs = orderIds.Split(',').ToList();
                    List<int> iOrderIDs = new List<int>();
                    if (strOrderIDs != null)
                    {
                        foreach (var item in strOrderIDs)
                        {
                            iOrderIDs.Add(TugBusinessLogic.Module.Util.toint(item));
                        }
                    }

                    TugDataEntities db = new TugDataEntities();
                    {
                        //0.验证账单编号是否已存在
                        var tmp = db.Billing.FirstOrDefault(u => u.BillingCode.Trim() == billing_code.Trim());
                        if (tmp != null)
                        {
                            var ret2 = new { code = Resources.Common.FAIL_CODE, message = Resources.Common.FAIL_MESSAGE };
                            //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                            return Json(ret2, JsonRequestBehavior.AllowGet);
                        }

                        //1.插入账单
                        TugDataModel.Billing aScheduler = new Billing();

                        aScheduler.CustomerID = custId;
                        aScheduler.JobNo = jobNo;
                        aScheduler.IsShowShipLengthRule = isShowShipLengthRule;
                        aScheduler.IsShowShipTEUSRule = isShowShipTEUSRule;
                        aScheduler.InvoiceType = "普通账单";

                        aScheduler.BillingTemplateID = billingTemplateId;
                        aScheduler.BillingTypeID = billingTypeId;
                        //aScheduler.BillingCode = TugBusinessLogic.Utils.AutoGenerateBillCode();
                        aScheduler.BillingCode = billing_code.Trim() ;
                        aScheduler.BillingName = "";
                        aScheduler.TimeTypeID = timeTypeId;
                        aScheduler.Discount = discount;
                        aScheduler.TotalRebate = 0;
                        aScheduler.Amount = amount;
                        aScheduler.Remark = remark;
                        aScheduler.Month = month;
                        aScheduler.UserDefinedCol10 = date;

                        if (ratio1 != null)
                            aScheduler.Ratio1 = (int?)Math.Round((float)ratio1, 2);
                        if (ratio2 != null)
                            aScheduler.Ratio2 = (int?)Math.Round((float)ratio2, 2);
                        if (ratio3 != null)
                            aScheduler.Ratio3 = (int?)Math.Round((float)ratio3, 2);
                        if (ratio4 != null)
                            aScheduler.Ratio4 = (int?)Math.Round((float)ratio4, 2);
                        if (ratio5 != null)
                            aScheduler.Ratio5 = (int?)Math.Round((float)ratio5, 2);
                        if (ratio6 != null)
                            aScheduler.Ratio6 = (int?)Math.Round((float)ratio6, 2);
                        if (ratio7 != null)
                            aScheduler.Ratio7 = (int?)Math.Round((float)ratio7, 2);
                        if (minTime != null)
                            aScheduler.MinTime = (int?)Math.Round((float)minTime, 2);

                        aScheduler.TimesNo = 0;
                        aScheduler.Status = "创建";
                        aScheduler.Phase = 0;

                        aScheduler.OwnerID = -1;
                        aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        aScheduler.UserID = Session.GetDataFromSession<int>("userid");

                        aScheduler.UserDefinedCol1 = "";
                        aScheduler.UserDefinedCol2 = "";
                        aScheduler.UserDefinedCol3 = "";
                        aScheduler.UserDefinedCol4 = "";

                        aScheduler.UserDefinedCol9 = "";

                        aScheduler = db.Billing.Add(aScheduler);
                        db.SaveChanges();

                        //2.插入账单、多个订单
                        List<BillingOrder> listBillingOrder = new List<BillingOrder>();
                        foreach (int orderId in iOrderIDs)
                        {
                            BillingOrder bo = new BillingOrder();
                            bo.BillingID = aScheduler.IDX;
                            bo.OrderID = orderId;
                            listBillingOrder.Add(bo);
                        }
                        db.BillingOrder.AddRange(listBillingOrder);
                        db.SaveChanges();

                        //3.插入账单的收费项目
                        List<InVoiceItem> listInVoiceItems = new List<InVoiceItem>();
                        listInVoiceItems = TugBusinessLogic.Utils.JSONStringToList<InVoiceItem>(jsonArrayItems);
                        if (listInVoiceItems != null)
                        {
                            foreach (InVoiceItem item in listInVoiceItems)
                            {
                                BillingItem bi = new BillingItem();
                                bi.BillingID = aScheduler.IDX;
                                bi.SchedulerID = item.SchedulerID;
                                bi.ItemID = item.ItemID;
                                bi.UnitPrice = item.UnitPrice;
                                bi.Currency = item.Currency;
                                bi.OwnerID = -1;
                                bi.UserID = Session.GetDataFromSession<int>("userid");
                                bi.CreateDate = bi.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                bi.UserDefinedCol1 = "";
                                bi.UserDefinedCol2 = "";
                                bi.UserDefinedCol3 = "";
                                bi.UserDefinedCol4 = "";

                                bi.UserDefinedCol9 = "";
                                bi.UserDefinedCol10 = "";

                                bi = db.BillingItem.Add(bi);
                                db.SaveChanges();
                            }
                        }

                        //4.插入账单的汇总项目
                        List<InVoiceSummaryItem> listInVoiceSummaryItems = new List<InVoiceSummaryItem>();
                        listInVoiceSummaryItems = TugBusinessLogic.Utils.JSONStringToList<InVoiceSummaryItem>(jsonArraySummaryItems);
                        if (listInVoiceSummaryItems != null)
                        {
                            foreach (InVoiceSummaryItem item in listInVoiceSummaryItems)
                            {
                                AmountSum amtSum = new AmountSum();
                                amtSum.CustomerID = custId;
                                amtSum.CustomerShipID = custShipId;
                                amtSum.BillingID = aScheduler.IDX;
                                amtSum.BillingDateTime = TugBusinessLogic.Utils.CNDateTimeToDateTime(aScheduler.CreateDate);
                                amtSum.SchedulerID = item.SchedulerID;
                                amtSum.Amount = item.Amount;
                                amtSum.FuelAmount = item.FuelPrice;
                                amtSum.Currency = item.Currency;
                                amtSum.Hours = item.Hours;
                                amtSum.Year = aScheduler.Month.Split('-')[0];//DateTime.Now.Year.ToString();
                                amtSum.Month = aScheduler.Month.Split('-')[1];// aScheduler.Month;
                                amtSum.OwnerID = -1;
                                amtSum.CreateDate = amtSum.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                amtSum.UserID = Session.GetDataFromSession<int>("userid");

                                amtSum = db.AmountSum.Add(amtSum);
                                db.SaveChanges();
                            }
                        }

                        //5.更新订单的字段 V_OrderInfor_HasInvoice	是否已有帳單
                        {
                            List<OrderInfor> odList = db.OrderInfor.Where(u => iOrderIDs.Contains(u.IDX)).ToList();
                            //throw new Exception();
                            if (odList != null)
                            {
                                foreach (OrderInfor od in odList)
                                {
                                    od.HasInvoice = "是";
                                    od.HasInFlow = "否";
                                    db.Entry(od).State = System.Data.Entity.EntityState.Modified;
                                    db.SaveChanges();
                                }
                            }
                        }

                        //6.更新订单服务表里的字段 HasBilling、HasBillingInFlow 是否已有帳單
                        {

                            List<string> strOrderServiceIDs = orderServiceIds.Split(',').ToList();
                            List<int> iOrderServiceIDs = new List<int>();
                            if (strOrderServiceIDs != null)
                            {
                                foreach (var item in strOrderServiceIDs)
                                {
                                    iOrderServiceIDs.Add(TugBusinessLogic.Module.Util.toint(item));
                                }
                            }

                            List<OrderService> ordSrvList = db.OrderService.Where(u => iOrderServiceIDs.Contains((int)u.IDX)).ToList();
                            //throw new Exception();
                            if (ordSrvList != null)
                            {
                                foreach (OrderService ods in ordSrvList)
                                {
                                    ods.HasBilling = "是";
                                    ods.HasBillingInFlow = "否";
                                    ods.BillingType = 0;
                                    db.Entry(ods).State = System.Data.Entity.EntityState.Modified;
                                    db.SaveChanges();
                                }
                            }
                        }

                        //7.更新客户船的船长、箱量
                        {
                            CustomerShip cs = db.CustomerShip.FirstOrDefault(u => u.IDX == custShipId);
                            if (cs != null)
                            {
                                cs.Length = customer_ship_length;
                                cs.TEUS = customer_ship_teus;
                                db.Entry(cs).State = System.Data.Entity.EntityState.Modified;
                                db.SaveChanges();
                            }
                        }

                        trans.Complete();

                        var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE, billing_id = aScheduler.IDX };
                        //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                        return Json(ret, JsonRequestBehavior.AllowGet);
                    }

                }
                catch (Exception ex)
                {
                    trans.Dispose();
                    var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE, billing_id = -1 };
                    //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                    return Json(ret, JsonRequestBehavior.AllowGet);
                }
            }
        }
Example #4
0
        public ActionResult AddSpecialInvoice(int custId, double amount, string month, string date, string billingCode, string jsonArrayItems)
        {
            this.Internationalization();

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {

                    TugDataEntities db = new TugDataEntities();
                    {
                        //0.验证账单编号是否已存在
                        var tmp = db.Billing.FirstOrDefault(u => u.BillingCode.Trim() == billingCode.Trim());
                        if (tmp != null)
                        {
                            var ret2 = new { code = Resources.Common.FAIL_CODE, message = "帳單編號已存在!" };
                            //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                            return Json(ret2, JsonRequestBehavior.AllowGet);
                        }

                        //1.插入账单
                        TugDataModel.Billing aScheduler = new Billing();

                        aScheduler.CustomerID = custId;
                        aScheduler.Amount = amount;
                        aScheduler.Month = month;
                        aScheduler.UserDefinedCol10 = date;
                        aScheduler.InvoiceType = "特殊账单";
                        aScheduler.BillingCode = billingCode.Trim();

                        aScheduler.TimesNo = 0;
                        aScheduler.Status = "创建";
                        aScheduler.Phase = 0;

                        aScheduler.OwnerID = -1;
                        aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        aScheduler.UserID = Session.GetDataFromSession<int>("userid");

                        aScheduler.UserDefinedCol1 = "";
                        aScheduler.UserDefinedCol2 = "";
                        aScheduler.UserDefinedCol3 = "";
                        aScheduler.UserDefinedCol4 = "";

                        aScheduler.UserDefinedCol9 = "";

                        aScheduler = db.Billing.Add(aScheduler);
                        db.SaveChanges();

                        //3.插入账单的收费项目
                        List<MySpecialBillingItem> listInVoiceItems = new List<MySpecialBillingItem>();
                        listInVoiceItems = TugBusinessLogic.Utils.JSONStringToList<MySpecialBillingItem>(jsonArrayItems);
                        if (listInVoiceItems != null)
                        {
                            foreach (MySpecialBillingItem item in listInVoiceItems)
                            {
                                SpecialBillingItem bi = new SpecialBillingItem();
                                bi.SpecialBillingID = aScheduler.IDX;
                                bi.OrderServiceID = item.OrderServiceID;
                                bi.CustomerShipName = item.CustomerShipName;
                                bi.FeulUnitPrice = item.FeulUnitPrice;
                                bi.ServiceDate = item.ServiceDate;
                                bi.ServiceNatureID = item.ServiceNatureID;
                                bi.ServiceNatureValue = item.ServiceNatureValue;
                                bi.ServiceNature = item.ServiceNature;
                                bi.ServiceUnitPrice = item.ServiceUnitPrice;
                                bi.TugNumber = item.TugNumber;

                                bi = db.SpecialBillingItem.Add(bi);
                                db.SaveChanges();

                                //更新订单服务的账单标记
                                {
                                    OrderService os = db.OrderService.First(u => u.IDX == item.OrderServiceID);
                                    os.HasBilling = "是";
                                    os.HasBillingInFlow = "否";
                                    os.BillingType = 1;
                                    db.Entry(os).State = System.Data.Entity.EntityState.Modified;
                                    db.SaveChanges();

                                    //更新服务对应的订单的账单标记;因为现在一个订单对应一个服务
                                    OrderInfor ordInfor = db.OrderInfor.FirstOrDefault(u => u.IDX == os.OrderID);
                                    if (ordInfor != null)
                                    {
                                        ordInfor.HasInvoice = "是";
                                        db.Entry(ordInfor).State = System.Data.Entity.EntityState.Modified;
                                        db.SaveChanges();
                                    }
                                }

                            }
                        }

                        //4.插入账单的汇总项目
                        TugBusinessLogic.Module.FinanceLogic.UpdateSpecialBillingSummarizeItems(aScheduler.IDX, (int)aScheduler.UserID);
                        //List<InVoiceSummaryItem> listInVoiceSummaryItems = new List<InVoiceSummaryItem>();
                        //listInVoiceSummaryItems = TugBusinessLogic.Utils.JSONStringToList<InVoiceSummaryItem>(jsonArraySummaryItems);
                        //if (listInVoiceSummaryItems != null)
                        //{
                        //    foreach (InVoiceSummaryItem item in listInVoiceSummaryItems)
                        //    {
                        //        AmountSum amtSum = new AmountSum();
                        //        amtSum.CustomerID = custId;
                        //        amtSum.CustomerShipID = custShipId;
                        //        amtSum.BillingID = aScheduler.IDX;
                        //        amtSum.BillingDateTime = TugBusinessLogic.Utils.CNDateTimeToDateTime(aScheduler.CreateDate);
                        //        amtSum.SchedulerID = item.SchedulerID;
                        //        amtSum.Amount = item.Amount;
                        //        amtSum.Currency = item.Currency;
                        //        amtSum.Hours = item.Hours;
                        //        amtSum.Year = DateTime.Now.Year.ToString();
                        //        amtSum.Month = aScheduler.Month;
                        //        amtSum.OwnerID = -1;
                        //        amtSum.CreateDate = amtSum.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //        amtSum.UserID = Session.GetDataFromSession<int>("userid");

                        //        amtSum = db.AmountSum.Add(amtSum);
                        //        db.SaveChanges();
                        //    }
                        //}

                        //5.更新订单的字段 V_OrderInfor_HasInvoice	是否已有帳單
                        //{
                        //    List<OrderInfor> odList = db.OrderInfor.Where(u => iOrderIDs.Contains(u.IDX)).ToList();
                        //    //throw new Exception();
                        //    if (odList != null)
                        //    {
                        //        foreach (OrderInfor od in odList)
                        //        {
                        //            od.HasInvoice = "是";
                        //            od.HasInFlow = "否";
                        //            db.Entry(od).State = System.Data.Entity.EntityState.Modified;
                        //            db.SaveChanges();
                        //        }
                        //    }
                        //}

                        trans.Complete();

                        var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE, billing_id = aScheduler.IDX };
                        //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                        return Json(ret, JsonRequestBehavior.AllowGet);
                    }

                }
                catch (Exception ex)
                {
                    trans.Dispose();
                    var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE, billing_id = -1 };
                    //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                    return Json(ret, JsonRequestBehavior.AllowGet);
                }
            }
        }
Example #5
0
        public ActionResult AddInvoice(int orderId, int billingTemplateId, int billingTypeId, int timeTypeId,
            string jobNo, string remark, double discount, double amount, string month, string jsonArrayItems)
        {
            this.Internationalization();

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {

                    TugDataEntities db = new TugDataEntities();
                    {
                        TugDataModel.Billing aScheduler = new Billing();

                        aScheduler.BillingTemplateID = billingTemplateId;
                        //aScheduler.BillingCode = TugBusinessLogic.Utils.AutoGenerateBillCode();
                        aScheduler.BillingName = "";

                        aScheduler.BillingTypeID = billingTypeId;
                        aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        aScheduler.Month = DateTime.Now.Month.ToString();
                        aScheduler.OrderID = orderId;
                        aScheduler.OwnerID = -1;

                        aScheduler.Phase = 0;
                        aScheduler.Remark = "";
                        aScheduler.Status = "创建";
                        aScheduler.TimesNo = 0;
                        aScheduler.TimeTypeID = timeTypeId;
                        aScheduler.UserID = Session.GetDataFromSession<int>("userid");
                        aScheduler.Discount = discount;
                        aScheduler.JobNo = jobNo;
                        aScheduler.Remark = remark;
                        aScheduler.Amount = amount;
                        aScheduler.Month = month;

                        aScheduler.UserDefinedCol1 = "";
                        aScheduler.UserDefinedCol2 = "";
                        aScheduler.UserDefinedCol3 = "";
                        aScheduler.UserDefinedCol4 = "";

                        //if (Request.Form["UserDefinedCol5"].Trim() != "")
                        //    aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                        //if (Request.Form["UserDefinedCol6"].Trim() != "")
                        //    aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                        //if (Request.Form["UserDefinedCol7"].Trim() != "")
                        //    aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                        //if (Request.Form["UserDefinedCol8"].Trim() != "")
                        //    aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                        aScheduler.UserDefinedCol9 = "";
                        aScheduler.UserDefinedCol10 = "";

                        aScheduler = db.Billing.Add(aScheduler);
                        db.SaveChanges();

                        List<InVoiceItem> listInVoiceItems = new List<InVoiceItem>();
                        listInVoiceItems = TugBusinessLogic.Utils.JSONStringToList<InVoiceItem>(jsonArrayItems);
                        if (listInVoiceItems != null)
                        {
                            foreach (InVoiceItem item in listInVoiceItems)
                            {
                                BillingItem bi = new BillingItem();
                                bi.BillingID = aScheduler.IDX;
                                bi.SchedulerID = item.SchedulerID;
                                bi.ItemID = item.ItemID;
                                bi.UnitPrice = item.UnitPrice;
                                bi.Currency = item.Currency;
                                bi.OwnerID = -1;
                                bi.UserID = Session.GetDataFromSession<int>("userid");
                                bi.CreateDate = bi.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                bi.UserDefinedCol1 = "";
                                bi.UserDefinedCol2 = "";
                                bi.UserDefinedCol3 = "";
                                bi.UserDefinedCol4 = "";

                                //if (Request.Form["UserDefinedCol5"].Trim() != "")
                                //    aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                                //if (Request.Form["UserDefinedCol6"].Trim() != "")
                                //    aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                                //if (Request.Form["UserDefinedCol7"].Trim() != "")
                                //    aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                                //if (Request.Form["UserDefinedCol8"].Trim() != "")
                                //    aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                                bi.UserDefinedCol9 = "";
                                bi.UserDefinedCol10 = "";

                                bi = db.BillingItem.Add(bi);
                                db.SaveChanges();
                            }
                        }

                        //更新订单的字段 V_OrderInfor_HasInvoice	是否已有帳單
                        {
                            OrderInfor od = db.OrderInfor.FirstOrDefault(u => u.IDX == orderId);
                            //throw new Exception();
                            if (od != null)
                            {
                                od.HasInvoice = "是";
                                db.Entry(od).State = System.Data.Entity.EntityState.Modified;
                                db.SaveChanges();
                            }
                        }

                        trans.Complete();

                        var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                        //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                        return Json(ret, JsonRequestBehavior.AllowGet);
                    }

                }
                catch (Exception)
                {
                    trans.Dispose();
                    var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                    //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                    return Json(ret, JsonRequestBehavior.AllowGet);
                }
            }
        }