Ejemplo n.º 1
0
 public void Add(PrjCompleted model)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         if (model != null)
         {
             PT_Prj_Completed_Detail detail = new PT_Prj_Completed_Detail {
                 ID               = model.ID,
                 PrjGuid          = new Guid?(model.PrjGuid),
                 PrepareStatus    = model.PrepareStatus,
                 UncompletedTrans = model.UncompletedTrans,
                 Rectification    = model.Rectification,
                 InputDate        = model.InputDate
             };
             PT_Prj_Completed completed = (from pc in entities.PT_Prj_Completed
                                           where pc.ID == model.PrjCompletedId
                                           select pc).FirstOrDefault <PT_Prj_Completed>();
             detail.PT_Prj_Completed = completed;
             PT_yhmc _yhmc = (from m in entities.PT_yhmc
                              where m.userCode == model.InputUser
                              select m).FirstOrDefault <PT_yhmc>();
             detail.PT_yhmc = _yhmc;
             entities.AddToPT_Prj_Completed_Detail(detail);
             entities.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
 public static void AddUser(string prjGuid, System.Collections.Generic.List <string> userCodes)
 {
     System.Guid guid = new System.Guid(prjGuid);
     using (pm2Entities context = new pm2Entities())
     {
         PTPrjInfoZTBUserService prjUserSer = new PTPrjInfoZTBUserService();
         prjUserSer.Delete(prjGuid);
         if (userCodes != null)
         {
             foreach (string code in userCodes)
             {
                 PT_yhmc yh = (
                     from m in context.PT_yhmc
                     where m.v_yhdm == code
                     select m).FirstOrDefault <PT_yhmc>();
                 if (yh != null)
                 {
                     PT_PrjInfo_ZTB_User user = new PT_PrjInfo_ZTB_User
                     {
                         Id       = System.Guid.NewGuid().ToString(),
                         PrjGuid  = guid,
                         UserCode = code
                     };
                     context.AddToPT_PrjInfo_ZTB_User(user);
                 }
             }
         }
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void Add(Progress entity)
 {
     if (entity != null)
     {
         using (pm2Entities entities = new pm2Entities())
         {
             PT_yhmc _yhmc = (from m in entities.PT_yhmc
                              where m.v_yhdm == entity.InputUser
                              select m).FirstOrDefault <PT_yhmc>();
             plus_progress _progress = new plus_progress {
                 ProgressId   = entity.ProgressId,
                 PrjId        = new Guid?(entity.PrjId),
                 ProgressName = entity.ProgressName,
                 IsMain       = entity.IsMain,
                 FlowState    = new int?(entity.FlowState),
                 Note         = entity.Note,
                 InputDate    = new DateTime?(entity.InputDate),
                 PT_yhmc      = _yhmc
             };
             entities.AddToplus_progress(_progress);
             if (entity.IsMain)
             {
                 List <plus_progress> list = (from m in entities.plus_progress
                                              where (m.PrjId == entity.PrjId) && m.IsMain
                                              select m).ToList <plus_progress>();
                 if (list.Count > 0)
                 {
                     foreach (plus_progress _progress2 in list)
                     {
                         _progress2.IsMain = false;
                     }
                 }
             }
             string str = Guid.NewGuid().ToString();
             plus_progress_version _version = new plus_progress_version {
                 ProgressVersionId = str,
                 ParentVersionId   = null,
                 VersionCode       = entity.VersionCode,
                 VersionName       = entity.ProgressName,
                 FlowState         = null,
                 InputDate         = new DateTime?(entity.InputDate),
                 IsLatest          = false,
                 Note          = entity.Note,
                 plus_progress = _progress
             };
             entities.AddToplus_progress_version(_version);
             List <string> userCodes = new List <string> {
                 entity.InputUser
             };
             if (entity.InputUser != "00000000")
             {
                 userCodes.Add("00000000");
             }
             Privilege.AddPrivilege(userCodes, _progress, entities);
             entities.SaveChanges();
         }
     }
 }
Ejemplo n.º 4
0
 public User GetChargeMan(int departmentId)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         PT_yhmc _yhmc = (from u in entities.PT_yhmc
                          where (u.i_bmdm == departmentId) && u.IsChargeMan
                          select u).FirstOrDefault <PT_yhmc>();
         return(this.ConvertToUser(_yhmc));
     }
 }
Ejemplo n.º 5
0
 public User GetByCode(string userCode)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         PT_yhmc _yhmc = (from u in entities.PT_yhmc
                          where u.v_yhdm == userCode
                          select u).FirstOrDefault <PT_yhmc>();
         return(this.ConvertToUser(_yhmc));
     }
 }
Ejemplo n.º 6
0
        private User ConvertToUser(PT_yhmc pt_user)
        {
            User user = null;

            if (pt_user != null)
            {
                user = new User {
                    UserCode     = pt_user.v_yhdm,
                    UserName     = pt_user.v_xm,
                    DepartmentId = pt_user.i_bmdm.Value
                };
            }
            return(user);
        }
Ejemplo n.º 7
0
 public void Update(PrjCompleted model)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         PT_Prj_Completed_Detail detail = (from m in entities.PT_Prj_Completed_Detail
                                           where (m.PrjGuid == model.PrjGuid) && (m.PT_Prj_Completed.ID == model.PrjCompletedId)
                                           select m).FirstOrDefault <PT_Prj_Completed_Detail>();
         detail.InputDate        = model.InputDate;
         detail.PrepareStatus    = model.PrepareStatus;
         detail.Rectification    = model.Rectification;
         detail.UncompletedTrans = model.UncompletedTrans;
         PT_yhmc _yhmc = (from n in entities.PT_yhmc
                          where n.v_yhdm == model.InputUser
                          select n).FirstOrDefault <PT_yhmc>();
         detail.PT_yhmc = _yhmc;
         entities.SaveChanges();
     }
 }