Exemple #1
0
 //从后台获取数据
 internal static void  LoadFromDAL(ContractFileInfo pContractFileInfo, ContractFile pContractFile)
 {
     pContractFileInfo.contractFileId   = pContractFile.ContractFileId;
     pContractFileInfo.contractFileName = pContractFile.ContractFileName;
     pContractFileInfo.phyFileName      = pContractFile.PhyFileName;
     pContractFileInfo.Loaded           = true;
 }
Exemple #2
0
        //数据持久化
        internal static void  SaveToDb(ContractFileInfo pContractFileInfo, ContractFile pContractFile, bool pIsNew)
        {
            pContractFile.ContractFileId   = pContractFileInfo.contractFileId;
            pContractFile.ContractFileName = pContractFileInfo.contractFileName;
            pContractFile.PhyFileName      = pContractFileInfo.phyFileName;
            pContractFile.IsNew            = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pContractFile.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(ContractFileInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pContractFileInfo.contractFileId = pContractFile.ContractFileId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)))
            {
                ResetCache();
            }
        }
Exemple #3
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(ContractFileInfo pContractFileInfoFrom, ContractFileInfo pContractFileInfoTo)
 {
     pContractFileInfoTo.ContractFileId   = pContractFileInfoFrom.contractFileId;
     pContractFileInfoTo.ContractFileName = pContractFileInfoFrom.contractFileName;
     pContractFileInfoTo.PhyFileName      = pContractFileInfoFrom.phyFileName;
     pContractFileInfoTo.Loaded           = pContractFileInfoFrom.Loaded;
 }
Exemple #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <ContractFileInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <ContractFileInfo>);
            }
            else
            {
                List <ContractFileInfo> list       = new List <ContractFileInfo>();
                ContractFileCollection  collection = new  ContractFileCollection();
                Query qry = new Query(ContractFile.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (ContractFile contractFile in collection)
                {
                    ContractFileInfo contractFileInfo = new ContractFileInfo();
                    LoadFromDAL(contractFileInfo, contractFile);
                    list.Add(contractFileInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Exemple #5
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsPageValid())
            {
                try
                {
                    ContractInfo contract = new ContractInfo();
                    contract.BeginDate = txtBeginDate.Text.ToString();
                    contract.SignName = ddlAuto.SelectedItem.Text.ToString();
                    if (UpFile.HasFile)
                    {
                        this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/Contract/" + UpFile.FileName));
                        ContractFileInfo cf = new ContractFileInfo();
                        cf.PhyFileName = UpFile.PostedFile.FileName;
                        cf.ContractFileName = UpFile.FileName.ToString();
                        cf.Save();
                        contract.ContractFileId = Convert.ToInt32(cf.ContractFileId);
                    }

                    contract.SignName = ddlAuto.SelectedItem.Text.ToString();
                    contract.ContractName = txtContractName.Text.ToString();
                    contract.ContractNum = txtContractNum.Text.ToString();
                    contract.MoneySum = txtMoney.Text.ToString();
                    contract.Save();
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ӳɹ���');</script>");

                }
                catch (Exception Ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('���ʧ�ܣ�" + Ex.Message + "');", true);
                }
            }
        }
Exemple #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     int fileid = Int32.Parse(Request.QueryString["fileid"]);//��ȡ�ļ���ID
     ContractFileInfo file = new ContractFileInfo(fileid);
     string fileName = file.ContractFileName;
     DownLoads(fileName);
 }
Exemple #7
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <ContractFileInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <ContractFileInfo> list = new List <ContractFileInfo>();

            Query q = ContractFile.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            ContractFileCollection collection = new  ContractFileCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (ContractFile contractFile  in collection)
            {
                ContractFileInfo contractFileInfo = new ContractFileInfo();
                LoadFromDAL(contractFileInfo, contractFile);
                list.Add(contractFileInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Exemple #8
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <ContractFileInfo> pList, ContractFileCollection pCollection)
 {
     foreach (ContractFile contractFile in pCollection)
     {
         ContractFileInfo contractFileInfo = new ContractFileInfo();
         LoadFromDAL(contractFileInfo, contractFile);
         pList.Add(contractFileInfo);
     }
 }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int fileid = Int32.Parse(Request.QueryString["fileid"]);//��ȡ�ļ���ID
            ContractFileInfo file = new ContractFileInfo(fileid);
            string fileName = file.ContractFileName;

            //��ȡ����·��
            //string DeskPath = Convert.ToString(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
            string DeskPath = Server.MapPath("~\\Files\\File");
            DownLoads(DeskPath, fileName);
        }
        public ContractFileInfo GetContractFileInfoById(int ContractFileId)
        {
            ContractFileInfo contractFileInfo  = null;//
            try
            {
                 contractFileInfo = new ContractFileInfo(ContractFileId);

            }
            catch (AppException)
            {
                return null;
            }

            return  contractFileInfo;
        }
        public ContractFileInfo GetContractFileInfoById(int ContractFileId)
        {
            ContractFileInfo contractFileInfo = null;             //

            try
            {
                contractFileInfo = new ContractFileInfo(ContractFileId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(contractFileInfo);
        }
Exemple #12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsPageValid())
            {
                try
                {
                    ContractApplyInfo CA = new ContractApplyInfo();
                    ContractFileInfo cf = new ContractFileInfo();
                    if (UpFile.HasFile)
                    {
                        this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/Contract/" + UpFile.FileName));
                       // cf.PhyFileName = UpFile.PostedFile.FileName;
                        cf.ContractFileName = UpFile.FileName.ToString();
                        cf.Save();
                        CA.ContractFileId = Convert.ToInt32(cf.ContractFileId);
                    }
                    CA.BeginDate = txtBeginDate.Text.ToString();
                    CA.SignName=ddlAuto.SelectedItem.Text.ToString();
                    CA.ContractName = txtContractName.Text.ToString();
                    CA.ContractNum=txtContractNum.Text.ToString();
                    CA.SheetNum = txtSheetNum.Text.ToString();
                    CA.Today = DateTime.Now.ToString("yyyyMMdd").Substring(2);
                    CA.BeginDate=txtBeginDate.Text.ToString();
                    CA.ApplyDate=txtApplyDate.Text.ToString();
                    CA.ContractDes=txtContractDes.Text.ToString();
                    CA.BigMoney=txtBigMoney.Text.ToString();
                    CA.SmallMoney=txtSmallMoney.Text.ToString();
                    CA.UseStampType=rblSignType.SelectedItem.Text.ToString();
                    CA.IsMoney=0;
                    if (ckbIsMoney.Checked)
                    {
                        CA.IsMoney = 1;
                    }
                    CA.ApplyName=lblEmployee.Text.ToString();
                    CA.DepartName=lblDepart.Text.ToString();
                    CA.State=0;
                    CA.Save();
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('保存成功!');</script>");

                }
                catch (Exception Ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('保存失败:" + Ex.Message + "');", true);
                }
            }
        }
Exemple #13
0
 private void LoadFromId(int contractFileId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)))
     {
         ContractFileInfo contractFileInfo = Find(GetList(), contractFileId);
         if (contractFileInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(contractFileInfo, this);
     }
     else
     {
         ContractFile contractFile = new ContractFile(contractFileId);
         if (contractFile.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, contractFile);
     }
 }
Exemple #14
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(ContractFileInfo pContractFileInfoTo)
 {
     Copy(this, pContractFileInfoTo);
 }
 public List <ContractFileInfo> GetContractFileInfoList()
 {
     return(ContractFileInfo.GetList());
 }
Exemple #16
0
 //数据持久化
 internal static void SaveToDb(ContractFileInfo pContractFileInfo, ContractFile  pContractFile,bool pIsNew)
 {
     pContractFile.ContractFileId = pContractFileInfo.contractFileId;
      		pContractFile.ContractFileName = pContractFileInfo.contractFileName;
      		pContractFile.PhyFileName = pContractFileInfo.phyFileName;
     pContractFile.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pContractFile.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(ContractFileInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pContractFileInfo.contractFileId = pContractFile.ContractFileId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)))
     {
         ResetCache();
     }
 }
Exemple #17
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< ContractFileInfo> pList, ContractFileCollection pCollection)
 {
     foreach (ContractFile contractFile in pCollection)
     {
         ContractFileInfo contractFileInfo = new ContractFileInfo();
         LoadFromDAL(contractFileInfo, contractFile );
         pList.Add(contractFileInfo);
     }
 }
Exemple #18
0
 //从后台获取数据
 internal static void LoadFromDAL(ContractFileInfo pContractFileInfo, ContractFile  pContractFile)
 {
     pContractFileInfo.contractFileId = pContractFile.ContractFileId;
      		pContractFileInfo.contractFileName = pContractFile.ContractFileName;
      		pContractFileInfo.phyFileName = pContractFile.PhyFileName;
     pContractFileInfo.Loaded=true;
 }
Exemple #19
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(ContractFileInfo pContractFileInfoTo)
 {
     Copy(this,  pContractFileInfoTo);
 }
Exemple #20
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ContractFileInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ContractFileInfo> list = new List< ContractFileInfo>();

            Query q = ContractFile .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ContractFileCollection  collection=new  ContractFileCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (ContractFile  contractFile  in collection)
            {
                ContractFileInfo contractFileInfo = new ContractFileInfo();
                LoadFromDAL(contractFileInfo,   contractFile);
                list.Add(contractFileInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Exemple #21
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<ContractFileInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< ContractFileInfo>;
     }
     else
     {
         List< ContractFileInfo>  list =new List< ContractFileInfo>();
         ContractFileCollection  collection=new  ContractFileCollection();
         Query qry = new Query(ContractFile.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(ContractFile contractFile in collection)
         {
             ContractFileInfo contractFileInfo= new ContractFileInfo();
             LoadFromDAL(contractFileInfo,contractFile);
             list.Add(contractFileInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(ContractFileInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Exemple #22
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(ContractFileInfo pContractFileInfoFrom, ContractFileInfo pContractFileInfoTo)
 {
     pContractFileInfoTo.ContractFileId = pContractFileInfoFrom.contractFileId;
      		pContractFileInfoTo.ContractFileName = pContractFileInfoFrom.contractFileName;
      		pContractFileInfoTo.PhyFileName = pContractFileInfoFrom.phyFileName;
     pContractFileInfoTo.Loaded=pContractFileInfoFrom.Loaded;
 }
 public object SaveContractFileInfo(ContractFileInfo contractFileInfo)
 {
     contractFileInfo.Save();
     return contractFileInfo . ContractFileId;
 }
 public List <ContractFileInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(ContractFileInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
 public void DeleteById(ContractFileInfo pContractFileInfo)
 {
     ContractFileInfo contractFileInfo = new ContractFileInfo(pContractFileInfo.ContractFileId);
     contractFileInfo.Delete();
 }
        public void DeleteById(ContractFileInfo pContractFileInfo)
        {
            ContractFileInfo contractFileInfo = new ContractFileInfo(pContractFileInfo.ContractFileId);

            contractFileInfo.Delete();
        }
 public object  SaveContractFileInfo(ContractFileInfo contractFileInfo)
 {
     contractFileInfo.Save();
     return(contractFileInfo.ContractFileId);
 }