Ejemplo n.º 1
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 <ContractInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <ContractInfo> list = new List <ContractInfo>();

            Query q = Contract.CreateQuery();

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

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Contract contract  in collection)
            {
                ContractInfo contractInfo = new ContractInfo();
                LoadFromDAL(contractInfo, contract);
                list.Add(contractInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
0
        //数据持久化
        internal static void  SaveToDb(ContractInfo pContractInfo, Contract pContract, bool pIsNew)
        {
            pContract.ContractId     = pContractInfo.contractId;
            pContract.ContractFileId = pContractInfo.contractFileId;
            pContract.SignName       = pContractInfo.signName;
            pContract.ContractNum    = pContractInfo.contractNum;
            pContract.ContractName   = pContractInfo.contractName;
            pContract.BeginDate      = pContractInfo.beginDate;
            pContract.MoneySum       = pContractInfo.moneySum;
            pContract.IsNew          = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pContract.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(ContractInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pContractInfo.contractId = pContract.ContractId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
            {
                ResetCache();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <ContractInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <ContractInfo>);
            }
            else
            {
                List <ContractInfo> list       = new List <ContractInfo>();
                ContractCollection  collection = new  ContractCollection();
                Query qry = new Query(Contract.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Contract contract in collection)
                {
                    ContractInfo contractInfo = new ContractInfo();
                    LoadFromDAL(contractInfo, contract);
                    list.Add(contractInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <ContractInfo> pList, ContractCollection pCollection)
 {
     foreach (Contract contract in pCollection)
     {
         ContractInfo contractInfo = new ContractInfo();
         LoadFromDAL(contractInfo, contract);
         pList.Add(contractInfo);
     }
 }
Ejemplo n.º 6
0
 //从后台获取数据
 internal static void  LoadFromDAL(ContractInfo pContractInfo, Contract pContract)
 {
     pContractInfo.contractId     = pContract.ContractId;
     pContractInfo.contractFileId = pContract.ContractFileId;
     pContractInfo.signName       = pContract.SignName;
     pContractInfo.contractNum    = pContract.ContractNum;
     pContractInfo.contractName   = pContract.ContractName;
     pContractInfo.beginDate      = pContract.BeginDate;
     pContractInfo.moneySum       = pContract.MoneySum;
     pContractInfo.Loaded         = true;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(ContractInfo pContractInfoFrom, ContractInfo pContractInfoTo)
 {
     pContractInfoTo.ContractId     = pContractInfoFrom.contractId;
     pContractInfoTo.ContractFileId = pContractInfoFrom.contractFileId;
     pContractInfoTo.SignName       = pContractInfoFrom.signName;
     pContractInfoTo.ContractNum    = pContractInfoFrom.contractNum;
     pContractInfoTo.ContractName   = pContractInfoFrom.contractName;
     pContractInfoTo.BeginDate      = pContractInfoFrom.beginDate;
     pContractInfoTo.MoneySum       = pContractInfoFrom.moneySum;
     pContractInfoTo.Loaded         = pContractInfoFrom.Loaded;
 }
Ejemplo n.º 8
0
        public ContractInfo GetContractInfoById(int ContractId)
        {
            ContractInfo contractInfo = null;             //

            try
            {
                contractInfo = new ContractInfo(ContractId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(contractInfo);
        }
Ejemplo n.º 9
0
        public ContractInfo GetContractInfoById(int ContractId)
        {
            ContractInfo contractInfo  = null;//
            try
            {
                 contractInfo = new ContractInfo(ContractId);

            }
            catch (AppException)
            {
                return null;
            }

            return  contractInfo;
        }
Ejemplo n.º 10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (rblOver.SelectedIndex == -1)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('请选择修正或通过!');</script>");
            }
            else
            {
                try
                {
                    int cid = Convert.ToInt32(Request["ContractApplyId"].ToString());
                    ContractApplyInfo ca = new ContractApplyInfo(cid);
                    ca.ManagerView = txtMangerView.Text.ToString();

                    if (rblOver.Items[0].Selected)
                    {
                        ca.State = 5;
                        ca.Save();

                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('您让申请人修正!');</script>");
                    }
                    else if (rblOver.Items[1].Selected)
                    {

                        ca.State = 4;
                        ca.Save();

                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('审批通过!');</script>");

                        ContractInfo ct = new ContractInfo();
                        ct.BeginDate = ca.BeginDate.ToString();
                        ct.ContractFileId = Convert.ToInt32(ca.ContractFileId);
                        ct.ContractName = ca.ContractName.ToString();
                        ct.ContractNum = ca.ContractNum.ToString();
                        ct.MoneySum = ca.SmallMoney.ToString();
                        ct.SignName = ca.SignName.ToString();
                        ct.Save();
                    }

                }
                catch (Exception Ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('保存失败:" + Ex.Message + "');", true);
                }
            }
        }
Ejemplo n.º 11
0
 private void LoadFromId(int contractId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
     {
         ContractInfo contractInfo = Find(GetList(), contractId);
         if (contractInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(contractInfo, this);
     }
     else
     {
         Contract contract = new Contract(contractId);
         if (contract.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, contract);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(ContractInfo pContractInfoTo)
 {
     Copy(this,  pContractInfoTo);
 }
Ejemplo n.º 13
0
 public object  SaveContractInfo(ContractInfo contractInfo)
 {
     contractInfo.Save();
     return(contractInfo.ContractId);
 }
Ejemplo n.º 14
0
 public List <ContractInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(ContractInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Ejemplo n.º 15
0
 public List <ContractInfo> GetContractInfoList()
 {
     return(ContractInfo.GetList());
 }
Ejemplo n.º 16
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<ContractInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ContractInfo> list = new List< ContractInfo>();

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

            foreach (Contract  contract  in collection)
            {
                ContractInfo contractInfo = new ContractInfo();
                LoadFromDAL(contractInfo,   contract);
                list.Add(contractInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Ejemplo n.º 17
0
 //从后台获取数据
 internal static void LoadFromDAL(ContractInfo pContractInfo, Contract  pContract)
 {
     pContractInfo.contractId = pContract.ContractId;
      		pContractInfo.contractFileId = pContract.ContractFileId;
      		pContractInfo.signName = pContract.SignName;
      		pContractInfo.contractNum = pContract.ContractNum;
      		pContractInfo.contractName = pContract.ContractName;
      		pContractInfo.beginDate = pContract.BeginDate;
      		pContractInfo.moneySum = pContract.MoneySum;
     pContractInfo.Loaded=true;
 }
Ejemplo n.º 18
0
 public object SaveContractInfo(ContractInfo contractInfo)
 {
     contractInfo.Save();
     return contractInfo . ContractId;
 }
Ejemplo n.º 19
0
 public void DeleteById(ContractInfo pContractInfo)
 {
     ContractInfo contractInfo = new ContractInfo(pContractInfo.ContractId);
     contractInfo.Delete();
 }
Ejemplo n.º 20
0
 //数据持久化
 internal static void SaveToDb(ContractInfo pContractInfo, Contract  pContract,bool pIsNew)
 {
     pContract.ContractId = pContractInfo.contractId;
      		pContract.ContractFileId = pContractInfo.contractFileId;
      		pContract.SignName = pContractInfo.signName;
      		pContract.ContractNum = pContractInfo.contractNum;
      		pContract.ContractName = pContractInfo.contractName;
      		pContract.BeginDate = pContractInfo.beginDate;
      		pContract.MoneySum = pContractInfo.moneySum;
     pContract.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pContract.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(ContractInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pContractInfo.contractId = pContract.ContractId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
     {
         ResetCache();
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< ContractInfo> pList, ContractCollection pCollection)
 {
     foreach (Contract contract in pCollection)
     {
         ContractInfo contractInfo = new ContractInfo();
         LoadFromDAL(contractInfo, contract );
         pList.Add(contractInfo);
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(ContractInfo pContractInfoFrom, ContractInfo pContractInfoTo)
 {
     pContractInfoTo.ContractId = pContractInfoFrom.contractId;
      		pContractInfoTo.ContractFileId = pContractInfoFrom.contractFileId;
      		pContractInfoTo.SignName = pContractInfoFrom.signName;
      		pContractInfoTo.ContractNum = pContractInfoFrom.contractNum;
      		pContractInfoTo.ContractName = pContractInfoFrom.contractName;
      		pContractInfoTo.BeginDate = pContractInfoFrom.beginDate;
      		pContractInfoTo.MoneySum = pContractInfoFrom.moneySum;
     pContractInfoTo.Loaded=pContractInfoFrom.Loaded;
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<ContractInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< ContractInfo>;
     }
     else
     {
         List< ContractInfo>  list =new List< ContractInfo>();
         ContractCollection  collection=new  ContractCollection();
         Query qry = new Query(Contract.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Contract contract in collection)
         {
             ContractInfo contractInfo= new ContractInfo();
             LoadFromDAL(contractInfo,contract);
             list.Add(contractInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(ContractInfo pContractInfoTo)
 {
     Copy(this, pContractInfoTo);
 }
Ejemplo n.º 25
0
        public void DeleteById(ContractInfo pContractInfo)
        {
            ContractInfo contractInfo = new ContractInfo(pContractInfo.ContractId);

            contractInfo.Delete();
        }