Esempio n. 1
0
        private Quotation GetQuotationOnUpdate(QuotationComplex source)
        {
            // Update 時不是所有欄位都讀出審核的部分沒資料出不能直接用automapper
            //
            Quotation temp = Mapper.Map <Quotation>(source.Quotation);
            Quotation info = this._Repository.Get(x => x.QuotationID == source.Quotation.QuotationID);

            info.QuotationID     = temp.QuotationID;
            info.QuotationDate   = temp.QuotationDate;
            info.WarehouseID     = temp.WarehouseID;
            info.CustomerID      = temp.CustomerID;
            info.TaxID           = temp.TaxID;
            info.ContactPerson   = temp.ContactPerson;
            info.ContactPhone    = temp.ContactPhone;
            info.InvoiceAddress  = temp.InvoiceAddress;
            info.ShippingAddress = temp.ShippingAddress;
            info.ShippingModeID  = temp.ShippingModeID;
            info.ShippingFee     = temp.ShippingFee;
            info.Total           = temp.Total;
            info.Remarks         = temp.Remarks;
            info.QuotePerson     = temp.QuotePerson;
            info.ValidateDate    = temp.ValidateDate;
            info.Activate        = temp.Activate;

            info.LastPerson = IdentityService.GetUserData().UserID;
            info.LastUpdate = DateTime.Now;

            return(info);
        }
Esempio n. 2
0
        public void Delete(QuotationComplex model)
        {
            #region 邏輯驗證
            if (model == null)//沒有資料
            {
                throw new Exception("MessageNoData".ToLocalized());
            }
            #endregion

            #region 變為Models需要之型別及邏輯資料
            var info = Mapper.Map <Quotation>(model.Quotation);
            #endregion

            #region Models資料庫

            foreach (QuotationDetailViewModel t in model.ChildList)
            {
                var d = Mapper.Map <QuotationDetail>(t);
                _DetailRepository.Delete(d);
            }

            this._Repository.Delete(info);
            this._UnitOfWork.SaveChange();
            #endregion
        }
Esempio n. 3
0
        public QuotationComplex Get(string id)
        {
            QuotationComplex info = new QuotationComplex();

            info = this.GetAll().Where(x => x.Quotation.QuotationID == id).Single();
            return(info);
        }
Esempio n. 4
0
        public QuotationComplex Create(QuotationComplex source)
        {
            #region 取資料


            #endregion

            #region 邏輯驗證


            #endregion

            #region 變為Models需要之型別及邏輯資料
            Quotation main = GetQuotationOnCreate(source);

            List <QuotationDetail> children = GetChildOnCreate(main, source);
            #endregion

            #region Models資料庫

            this._Repository.Create(main);

            foreach (QuotationDetail item in children)
            {
                this._DetailRepository.Create(item);
            }

            this._UnitOfWork.SaveChange();
            #endregion

            return(this.Get(main.QuotationID));
        }
Esempio n. 5
0
        private void InitViewBag(QuotationComplex info)
        {
            // 倉庫
            ViewBag.WareHouseList =
                new SelectList(this._GlobalService.GetWarehouseList(), "Key", "Value", info?.Quotation.WarehouseID);

            // 公司
            ViewBag.CompanyList =
                new SelectList(this._GlobalService.GetCustomerList(), "Value", "Display", info?.Quotation?.CustomerID);

            // 運送方式
            ViewBag.ShippingModeList =
                new SelectList(this._GlobalService.GetShippingModeList(), "Key", "Value", null);

            // 審核結果
            ViewBag.ResultTypeList =
                new SelectList(ResultType.GetAll(), "value", "Text", info?.Quotation.Result);

            // 報價人
            //ViewBag.UserList =
            //   new SelectList(this._GlobalService.GetUserList(), "Value", "Display", info?.Quotation.QuotePerson);
            ViewBag.UserList =
                new SelectList(this._GlobalService.GetUserList(), "Value", "Display", info?.Quotation.QuotePerson);


            ViewBag.YseNoList =
                new SelectList(YesNo.GetAll(), "value", "Text", info?.Quotation.Activate);
        }
Esempio n. 6
0
        public ActionResult DeleteConfirmed(QuotationComplex model)
        {
            ResultModel result = new ResultModel();

            try
            {
                #region Service資料庫
                if (this._QuotationComplexService.IsUsed(model))
                {
                    result.Message           = "MessageChaneDelete2UpdateComplete".ToLocalized();
                    model.Quotation.Activate = YesNo.No.Value;
                    this._QuotationComplexService.Update(model);
                }
                else
                {
                    this._QuotationComplexService.Delete(model);
                }
                #endregion
            }
            catch (Exception ex)
            {
                #region  錯誤時錯誤訊息
                result.Status  = false;
                result.Message = ex.Message.ToString();
                #endregion
            }
            return(Json(result));
        }
Esempio n. 7
0
 public bool IsUsed(QuotationComplex info)
 {
     //var query = this._Repository.Get(x => x.InquiryID == model.Inquiry.InquiryID);
     //var result = query.Product.Any();
     //this._Repository.HandleDetached(query); //
     //return result;
     return(true); // 目前不知關聯到哪些資料表
 }
Esempio n. 8
0
        private Quotation GetQuotationOnAudit(QuotationComplex source)
        {
            Quotation info = Mapper.Map <Quotation>(source.Quotation);

            info.LastPerson = IdentityService.GetUserData().UserID;
            info.LastUpdate = DateTime.Now;

            return(info);
        }
Esempio n. 9
0
        private Quotation GetQuotationOnCreate(QuotationComplex source)
        {
            Quotation info = Mapper.Map <Quotation>(source.Quotation);

            // 取得詢價單號;目前由使用者自型輸入
            info.QuotationID = GenerateQuotationID(info);
            info.LastPerson  = IdentityService.GetUserData().UserID;
            info.LastUpdate  = DateTime.Now;
            return(info);
        }
Esempio n. 10
0
        private List <QuotationDetail> GetChildOnCreate(Quotation master, QuotationComplex source)
        {
            List <QuotationDetail> infos = new List <QuotationDetail>();
            var wanted = source.ChildList.Where(x => x.IsDirty == true);

            foreach (var item in wanted)
            {
                QuotationDetail temp = Mapper.Map <QuotationDetail>(item);
                temp.QuotationID = master.QuotationID;
                temp.LastPerson  = IdentityService.GetUserData().UserID;
                temp.LastUpdate  = DateTime.Now;
                infos.Add(temp);
            }
            return(infos);
        }
Esempio n. 11
0
        public void Audit(QuotationComplex source)
        {
            #region 取資料


            #endregion

            #region 邏輯驗證


            #endregion

            #region 變為Models需要之型別及邏輯資料
            Quotation main = GetQuotationOnAudit(source);

            List <QuotationDetail> children = GetChildOnCreate(main, source);
            #endregion

            #region Models資料庫

            this._Repository.Update(main);

            foreach (QuotationDetail item in children)
            {
                if (item.SeqNo == 0)
                {
                    this._DetailRepository.Create(item);
                }
                else
                {
                    this._DetailRepository.Update(item);
                }
            }

            this._UnitOfWork.SaveChange();
            #endregion
        }
Esempio n. 12
0
        public ActionResult Edit(QuotationComplex info)
        {
            ResultModel result = new ResultModel();

            try
            {
                #region 驗證Model
                if (!ModelState.IsValid)
                {
                    throw new Exception(ModelStateErrorClass.FormatToString(ModelState));
                }
                // 至少需有一筆明細資料
                if (info.ChildList == null || info.ChildList.Count == 0)
                {
                    ModelState.AddModelError("ChildList", "至少需有一筆明細資料。");
                }
                else
                {
                    var query =
                        info.ChildList
                        .GroupBy(x => x.ProductID)
                        .ToDictionary(x => x.Key, x => x.Count())
                        .Where(x => x.Value > 1)
                        .ToList();

                    CDMS.Web.Common.DuplicateValidator validator =
                        new CDMS.Web.Common.DuplicateValidator(query);

                    if (validator.Message.Count > 0)
                    {
                        foreach (var s in validator.Message)
                        {
                            ModelState.AddModelError("ChildList", s);
                        }
                    }
                }

                if (!ModelState.IsValid)
                {
                    string message = ModelStateErrorClass.FormatToString(ModelState);

                    result.Status  = false;
                    result.Message = message;

                    return(Json(result));
                }
                #endregion

                #region 前端資料變後端用資料ViewModel時用

                #endregion

                #region Service資料庫
                this._QuotationComplexService.Audit(info);
                #endregion

                #region  息頁面設定
                result.Status      = true;
                result.CloseWindow = false;
                result.Url         = Url.Action("Edit", new { id = info.Quotation.QuotationID });
                result.Message     = "MessageComplete".ToLocalized();
                #endregion
            }
            catch (Exception ex)
            {
                #region  錯誤時錯誤訊息
                result.Status  = false;
                result.Message = ex.Message.ToString();
                #endregion
            }
            return(Json(result));
        }