Beispiel #1
0
        public JsonResult DeleteB06(B06ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Message_Type.parameter_Error.GetDescription();

            try
            {
                MSGReturnModel resultDelete = B0Repository.deleteB06(dataModel);

                result.RETURN_FLAG = resultDelete.RETURN_FLAG;
                result.DESCRIPTION = Message_Type.delete_Success.GetDescription();

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = resultDelete.DESCRIPTION;
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }

            return(Json(result));
        }
Beispiel #2
0
        public JsonResult GetB06Data(B06ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Message_Type.not_Find_Any.GetDescription();

            try
            {
                var queryResult = B0Repository.getB06(dataModel);

                result.RETURN_FLAG = queryResult.Item1;

                Cache.Invalidate(CacheList.B06DbfileData);             //清除
                Cache.Set(CacheList.B06DbfileData, queryResult.Item2); //把資料存到 Cache

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = Message_Type.not_Find_Any.GetDescription();
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }

            return(Json(result));
        }
Beispiel #3
0
        public MSGReturnModel deleteB06(B06ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    DateTime processingDate = DateTime.Parse(dataModel.Processing_Date);

                    var query = db.IFRS9_Foward_Looking_Parm
                                .Where(x => x.Processing_Date == processingDate &&
                                       x.Product_Code == dataModel.Product_Code &&
                                       x.PRJID == dataModel.PRJID &&
                                       x.FLOWID == dataModel.FLOWID &&
                                       x.CompID == dataModel.CompID);

                    db.IFRS9_Foward_Looking_Parm.RemoveRange(query);

                    db.SaveChanges();

                    result.RETURN_FLAG = true;
                }
                catch (Exception ex)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = ex.Message;
                }
            }

            return(result);
        }
Beispiel #4
0
        public MSGReturnModel saveB06(string actionType, B06ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    IFRS9_Foward_Looking_Parm editData = new IFRS9_Foward_Looking_Parm();

                    if (actionType == "Add")
                    {
                        dataModel.Processing_Date = DateTime.Now.ToString("yyyy/MM/dd");
                        DateTime processingDate = DateTime.Parse(dataModel.Processing_Date);

                        List <IFRS9_Foward_Looking_Parm> Datas = db.IFRS9_Foward_Looking_Parm.AsNoTracking().ToList();

                        if (Datas
                            .Where(x => x.Processing_Date == processingDate &&
                                   x.Product_Code == dataModel.Product_Code &&
                                   x.PRJID == "無" &&
                                   x.FLOWID == "無" &&
                                   x.CompID == "無")
                            .Any() == true)
                        {
                            result.RETURN_FLAG = false;
                            result.DESCRIPTION = $"資料重複:資料處理日期={dataModel.Processing_Date} 的資料 已存在";
                            return(result);
                        }

                        editData.CPD_Segment_Code = "";
                        editData.Delta_Q          = double.Parse(dataModel.Delta_Q);
                        editData.Processing_Date  = processingDate;
                        editData.Product_Code     = dataModel.Product_Code;
                        editData.PRJID            = "無";
                        editData.FLOWID           = "無";
                        editData.CompID           = "無";
                    }
                    else if (actionType == "Modify")
                    {
                    }

                    if (actionType == "Add")
                    {
                        db.IFRS9_Foward_Looking_Parm.Add(editData);
                    }

                    db.SaveChanges();

                    result.RETURN_FLAG = true;
                }
                catch (Exception ex)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = ex.Message;
                }
            }

            return(result);
        }
Beispiel #5
0
        public Tuple <bool, List <B06ViewModel> > getB06(B06ViewModel dataModel)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.IFRS9_Foward_Looking_Parm.Any())
                {
                    var query = from q in db.IFRS9_Foward_Looking_Parm.AsNoTracking()
                                select q;

                    if (dataModel.Processing_Date.IsNullOrWhiteSpace() == false)
                    {
                        DateTime processingDate = DateTime.Parse(dataModel.Processing_Date);
                        query = query.Where(x => x.Processing_Date >= processingDate);
                    }
                    if (!dataModel.to.IsNullOrWhiteSpace())
                    {
                        DateTime to = DateTime.Parse(dataModel.to);
                        query = query.Where(x => x.Processing_Date <= to);
                    }

                    query = query.Where(x => x.Product_Code == dataModel.Product_Code, dataModel.Product_Code.IsNullOrWhiteSpace() == false);
                    query = query.Where(x => x.PRJID == dataModel.PRJID, dataModel.PRJID.IsNullOrWhiteSpace() == false);
                    query = query.Where(x => x.FLOWID == dataModel.FLOWID, dataModel.FLOWID.IsNullOrWhiteSpace() == false);
                    query = query.Where(x => x.CompID == dataModel.CompID, dataModel.CompID.IsNullOrWhiteSpace() == false);

                    return(new Tuple <bool, List <B06ViewModel> >(query.Any(), query.AsEnumerable()
                                                                  .Select(x => { return DbToB06Model(x); }).ToList()));
                }
            }

            return(new Tuple <bool, List <B06ViewModel> >(false, new List <B06ViewModel>()));
        }
Beispiel #6
0
        public Tuple <bool, List <B06ViewModel> > getB06All(B06ViewModel dataModel)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.IFRS9_Foward_Looking_Parm.Any())
                {
                    return(new Tuple <bool, List <B06ViewModel> >
                           (
                               true,
                               (
                                   from q in db.IFRS9_Foward_Looking_Parm.AsNoTracking().Where(x => x.Product_Code == dataModel.Product_Code)
                                   .AsEnumerable()
                                   select DbToB06Model(q)
                               ).ToList()
                           ));
                }
            }

            return(new Tuple <bool, List <B06ViewModel> >(true, new List <B06ViewModel>()));
        }