Ejemplo n.º 1
0
        /// <summary>
        /// 养护单位详情
        /// </summary>
        /// <param name="companyid"></param>
        /// <returns></returns>
        public YH_CompanyModel GetConserbationModel(int companyid)
        {
            List <YH_CompanyModel> list = new List <YH_CompanyModel>();

            using (Entities db = new Entities())
            {
                IQueryable <YH_CompanyModel> queryable = from a in db.yh_companys
                                                         join b_join in db.base_zds on a.companytype equals b_join.zd_id into bTmp
                                                         from b in bTmp.DefaultIfEmpty()
                                                         where a.companyid == companyid
                                                         select new YH_CompanyModel
                {
                    companyid       = a.companyid,
                    companyname     = a.companyname,
                    legal           = a.legal,
                    contact         = a.contact,
                    companytype     = a.companytype,
                    isenadle        = a.isenadle,
                    address         = a.address,
                    companytypename = b == null ? "" : b.zd_name,
                    createtime      = a.createtime,
                    email           = a.email,
                    faxnumber       = a.faxnumber,
                    telephone       = a.telephone,
                    mobilephone     = a.mobilephone
                };
                YH_FileDAL      dal   = new YH_FileDAL();
                YH_CompanyModel model = queryable.FirstOrDefault();
                model.filelist = dal.GetFileList(3, model.companyid);
                return(model);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 养护日志详情
 /// </summary>
 /// <param name="yhlogid"></param>
 /// <returns></returns>
 public YH_YhLogModel GetYhLogModel(int yhlogid)
 {
     using (Entities db = new Entities())
     {
         IQueryable <YH_YhLogModel> queryable = from a in db.yh_yhlogs
                                                join b_join in db.yh_contracts on a.yhcontract equals b_join.contractid into btmp
                                                from b in btmp.DefaultIfEmpty()
                                                join c_join in db.base_users on a.createuserid equals c_join.id into ctmp
                                                from c in ctmp.DefaultIfEmpty()
                                                where a.yhlogid == yhlogid
                                                select new YH_YhLogModel
         {
             yhlogid        = a.yhlogid,
             yhcontract     = a.yhcontract,
             patroltime     = a.patroltime,
             patrolexplain  = a.patrolexplain,
             createtime     = a.createtime,
             createuserid   = a.createuserid,
             yhcontractname = b == null ? "" : b.contractname,
             createusername = c == null ? "" : c.displayname,
         };
         YH_FileDAL    dal   = new YH_FileDAL();
         YH_YhLogModel model = queryable.FirstOrDefault();
         model.filelist = dal.GetFileList(2, model.yhlogid);
         return(model);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 查看养护合同详情
        /// </summary>
        /// <param name="contractid"></param>
        /// <returns></returns>
        public YH_ContractModel GetContractModel(int contractid)
        {
            using (Entities db = new Entities())
            {
                #region linq
                //IQueryable<YH_ContractModel> queryable = from a in db.yh_contracts
                //                                         join b_join in db.base_zds on a.contacttype equals b_join.zd_id into btmp
                //                                         from b in btmp.DefaultIfEmpty()
                //                                         join c_join in db.base_zds on a.contacttype equals c_join.zd_id into ctmp
                //                                         from c in ctmp.DefaultIfEmpty()
                //                                         join d_join in db.base_users on a.createuserid equals d_join.id into dtmp
                //                                         from d in dtmp.DefaultIfEmpty()
                //                                         where b.zd_type == "type_yhht_yhnr" && a.contractid == contractid && c.zd_type == "type_yhht_yhht"
                //                                         select new YH_ContractModel
                //                                         {
                //                                             contractid = a.contractid,
                //                                             contractname = a.contractname,
                //                                             contacttype = a.contacttype,
                //                                             contacttypename = b == null ? "" : b.zd_name,
                //                                             jfdw = a.jfdw,
                //                                             jfdb = a.jfdb,
                //                                             yfdw = a.yfdw,
                //                                             yfdb = a.yfdb,
                //                                             htzxzt = a.htzxzt,
                //                                             createtime = a.createtime,
                //                                             patrolexplain = a.patrolexplain,
                //                                             starttime = a.starttime,
                //                                             endtime = a.endtime,
                //                                             signdate = a.signdate,
                //                                             summoney = a.summoney,
                //                                             currentmoney = a.currentmoney,
                //                                             contactendtime = a.contactendtime,
                //                                             contracttypename = c == null ? "" : c.zd_name,
                //                                             contracttype = a.contracttype,
                //                                             createusername = d == null ? "" : d.displayname,
                //                                             createuserid = a.createuserid,
                //                                         };
                #endregion
                string sql = string.Format(@"select 
yhcon.*,
a.zd_name contacttypename,b.zd_name  contracttypename,users.displayname createusername
from yh_contracts yhcon
left join (select * from yh_files fi where fi.filetype=1) as file on yhcon.contractid= file.sourceid
left join (select * from base_zds zdsOne where zdsOne.zd_type='type_yhht_yhnr') as a on yhcon.contacttype=a.zd_id
left join (select * from base_zds zdsOne where zdsOne.zd_type='type_yhht_yhht') as b on yhcon.contracttype=b.zd_id
left join base_users users on yhcon.createuserid=users.id
where yhcon.contractid=" + contractid);
                IEnumerable <YH_ContractModel> queryable = db.Database.SqlQuery <YH_ContractModel>(sql);

                YH_FileDAL       dal   = new YH_FileDAL();
                YH_ContractModel model = queryable.FirstOrDefault();
                if (model != null)
                {
                    if (model.htzxzt == 1)
                    {
                        model.contractstate = "执行中";
                    }
                    else if (model.htzxzt == 2)
                    {
                        model.contractstate = "已执行";
                    }
                    else if (model.htzxzt == 3)
                    {
                        model.contractstate = "已停止";
                    }
                    model.filelist = dal.GetFileList(1, contractid);
                }
                return(model);
            }
        }