コード例 #1
0
 /// <summary>
 /// InsertBill - them thông tin bill
 /// </summary>
 /// <param name="bill"></param>
 /// <returns></returns>
 public bool InsertBill(Bill bill)
 {
     return(billDao.InsertBill(bill));
 }
コード例 #2
0
        public ActionResult Approve(string key = "")
        {
            if (!SessionCheck(Define.Session.SESSION_CHECK))
            {
                return(ErrorPage("/Home/Error"));
            }
            if (!CheckAuth())
            {
                LogWriter.Instance().LogWrite(UserSession.UserId, "/Delivery/Approve - Error");
                return(base.Logout());
            }
            LogWriter.Instance().LogWrite(UserSession.UserId, "/Delivery/Approve");
            //정상경로가 아님
            if (!String.IsNullOrEmpty(key) && !Object.Equals(Define.APPROVE, key) && !Object.Equals(Define.CANCEL, key))
            {
                return(ErrorPage("/Home/Error"));
            }
            Document              pDoc      = (Document)Session["orderDOC"];
            OrderTable            pOrder    = (OrderTable)Session["order"];
            IList <OrderTableSub> pSubOrder = (IList <OrderTableSub>)Session["orderSub"];
            String InputSessionkey          = (String)Session["orderCheck"];

            Session["orderDOC"]   = null;
            Session["order"]      = null;
            Session["orderSub"]   = null;
            Session["orderCheck"] = null;

            //비정상경로
            if (pDoc == null || pOrder == null || pSubOrder == null || InputSessionkey == null)
            {
                return(Redirect("/Obtain/Order"));
            }
            //비정상경로
            if (!ORDERSESSIONKEY.Equals(InputSessionkey))
            {
                return(Redirect("/Obtain/Order"));
            }

            //등록처리
            if (Object.Equals(Define.APPROVE, key))
            {
                orderTableDao.Approve(pOrder.Idx, App_Code.Define.STATE_APPLY, CompanySession.CompanyCode);

                //납품확인서 처리
                DeliveryTable delivery = new DeliveryTable();
                delivery.OrderCompany          = pOrder.OrderName;
                delivery.OrderAddress          = pOrder.OrderAddress;
                delivery.OrderSavedate         = pOrder.OrderSaveDate;
                delivery.InorderCompany        = CompanySession.CompanyName;
                delivery.InorderRepresentative = CompanySession.Representative;
                delivery.Creater     = UserSession.UserName;
                delivery.CreateDate  = DateTime.Now;
                delivery.State       = App_Code.Define.STATE_NORMAL.ToString();
                delivery.CompanyCode = CompanySession.CompanyCode;
                deliveryTableDao.InsertDelivery(delivery);
                Int64 deliverylastIndex = deliveryTableDao.GetScopeIndentity();

                Document doc = new Document();
                doc.DocumentCode  = documentDao.CreateCode();
                doc.DocumentType  = DOCUMENTDELIVERYCODE;
                doc.DocumentIndex = delivery.Idx;
                doc.CreateDate    = DateTime.Now;
                doc.Creater       = UserSession.UserName;
                doc.State         = App_Code.Define.STATE_NORMAL.ToString();
                doc.CompanyCode   = CompanySession.CompanyCode;
                documentDao.InsertDocument(doc);

                foreach (OrderTableSub data in pSubOrder)
                {
                    //재고처리
                    ProductFlow product = new ProductFlow();
                    product.ProductIndex     = data.ProductIndex;
                    product.ProductAmount    = data.ProductAmount;
                    product.ProductSellPrice = data.ProductPrice;
                    product.State            = Define.ProductFlow.OUTCOMESTANBY.ToString();
                    product.CompanyCode      = CompanySession.CompanyCode;
                    product.ApplyType        = pOrder.Idx;
                    product.Creater          = UserSession.UserId;
                    product.CreteDate        = DateTime.Now;
                    productFlowDao.InsertProductFlow(product);

                    //납품확인서(서브) 처리
                    DeliveryTableSub deliverySub = new DeliveryTableSub();
                    deliverySub.DeliveryKey   = delivery.Idx;
                    deliverySub.Number        = data.Number;
                    deliverySub.ProductIndex  = data.ProductIndex;
                    deliverySub.ProductSpec   = data.ProductSpec;
                    deliverySub.ProductType   = data.ProductType;
                    deliverySub.ProductAmount = data.ProductAmount;
                    deliverySub.ProductPrice  = data.ProductPrice;
                    deliverySub.ProductVat    = 0;
                    deliverySub.Creater       = UserSession.UserId;
                    deliverySub.CreateDate    = DateTime.Now;
                    deliverySub.State         = App_Code.Define.STATE_NORMAL.ToString();
                    deliverySub.CompanyCode   = CompanySession.CompanyCode;
                    deliveryTableSubDao.InsertDeliveryTableSub(deliverySub);
                }
                //청구서 작성
                Bill bill = new Bill();
                bill.InorderCompany        = CompanySession.CompanyName;
                bill.InorderRepresentative = CompanySession.Representative;
                bill.InorderPost           = CompanySession.CompanyPostNumber;
                bill.InorderAddress        = CompanySession.CompanyAddress;
                bill.OrderCompany          = pOrder.OrderName;
                bill.OrderAddress          = pOrder.OrderAddress;
                bill.BillDate    = pOrder.PayDate;
                bill.BillMoney   = pOrder.OrderMoney;
                bill.BillTax     = 0;
                bill.BillTotal   = bill.BillMoney + bill.BillTax;
                bill.Creater     = UserSession.UserName;
                bill.CreateDate  = DateTime.Now;
                bill.State       = App_Code.Define.STATE_NORMAL.ToString();
                bill.CompanyCode = CompanySession.CompanyCode;
                billDao.InsertBill(bill);
                Int64 billLastIndex = billDao.GetScopeIndentity();

                Document doc2 = new Document();
                doc2.DocumentCode  = documentDao.CreateCode();
                doc2.DocumentType  = DOCUMENTBILLCODE;
                doc2.DocumentIndex = bill.Idx;
                doc2.CreateDate    = DateTime.Now;
                doc2.Creater       = UserSession.UserName;
                doc2.State         = App_Code.Define.STATE_NORMAL.ToString();
                doc2.CompanyCode   = CompanySession.CompanyCode;
                documentDao.InsertDocument(doc2);

                //기본ViewBag 설정
                ViewSetting(pDoc, pOrder, pSubOrder);
                ViewBag.Commit = COMMIT_SHOUNINN_COMPLATE;
                Session[Define.Session.ACTION] = "DeliveryApproveList";
                return(View("~/Views/Delivery/Web/DeliveryApproveCheck.cshtml", Define.MASTER_VIEW));
            }
            else if (Object.Equals(Define.CANCEL, key))
            {
                //등록
                orderTableDao.Approve(pOrder.Idx, App_Code.Define.STATE_DELETE, CompanySession.CompanyCode);
                pSubOrder.AsParallel().ForAll((data) =>
                {
                    orderTableSubDao.ModifyState(data.Idx, App_Code.Define.STATE_DELETE, CompanySession.CompanyCode);
                });
                ViewBag.Commit = COMMIT_SHOUNINN_CANCLE;
                //기본ViewBag 설정
                ViewSetting(pDoc, pOrder, pSubOrder);
                Session[Define.Session.ACTION] = "DeliveryApproveList";
                return(View("~/Views/Delivery/Web/DeliveryApproveCheck.cshtml", Define.MASTER_VIEW));
            }
            else
            {
                return(ErrorPage("/Home/Error"));
            }
        }