示例#1
0
        public static List <TR01B> BeforSave(List <TR01BViewModel> data, EditType editType)
        {
            List <TR01B> list = new List <TR01B>();

            if (editType == EditType.AddNew)
            {
                foreach (var item in data)
                {
                    item.CREATE_USER = UserInfo.Id;
                    item.CREATE_DATE = DateTime.Now;
                    list.Add(ToEntity(item));
                }
            }
            else
            {
                TR01Service _Service    = new TR01Service();
                var         DBTR01BList = _Service.GetB(data.Select(x => x.TR01B_ID).ToList());
                foreach (var item in DBTR01BList)
                {
                    var tempData = data.First(x => x.TR01B_ID == item.TR01B_ID);
                    tempData.TR01A_ID    = item.TR01A_ID;
                    tempData.CREATE_USER = item.CREATE_USER;
                    tempData.CREATE_DATE = item.CREATE_DATE;
                    tempData.UPDATE_USER = UserInfo.Id;
                    tempData.UPDATE_DATE = DateTime.Now;
                    list.Add(ToEntity(tempData));
                }
            }
            return(list);
        }
示例#2
0
        public static bool ValidateRemove(TR01AViewModel model, List <TR01BViewModel> updateDetail)
        {
            if (model.TR01A_ID > 0)
            {
                TR01Service _Service  = new TR01Service();
                var         hasMaster = _Service.GetA(model.TR01A_ID);
                if (hasMaster == null)
                {
                    return(false);
                }

                if (updateDetail != null && updateDetail.Count > 0)
                {
                    var            TR01B_IDList = updateDetail.Select(x => x.TR01B_ID).ToList();
                    PURSysEntities _Entity      = new PURSysEntities();
                    var            DBCount      = _Entity.TR01B.Where(x => TR01B_IDList.Contains(x.TR01B_ID)).Count();
                    if (DBCount != TR01B_IDList.Count())
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#3
0
 //==========================BeforSave==========================
 public static TR01A BeforSave(TR01AViewModel data)
 {
     if (data.TR01A_ID == 0)//Adding New
     {
         data.PUR_NO      = new PURSysEntities().Database.SqlQuery <string>("select dbo.Get_PUR_NO()").FirstOrDefault();
         data.CREATE_USER = UserInfo.Id;
         data.CREATE_DATE = DateTime.Now;
         data.CFN_YN      = "N";
     }
     else//Update
     {
         TR01Service _Service = new TR01Service();
         var         TR01A    = _Service.GetA(data.TR01A_ID);
         data.CREATE_USER = TR01A.CREATE_USER;
         data.CREATE_DATE = TR01A.CREATE_DATE;
         data.UPDATE_USER = UserInfo.Id;
         data.UPDATE_DATE = DateTime.Now;
     }
     return(ToEntity(data));
 }