/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(OfferFileInfo pOfferFileInfoFrom, OfferFileInfo pOfferFileInfoTo) { pOfferFileInfoTo.OfferFileId = pOfferFileInfoFrom.offerFileId; pOfferFileInfoTo.OfferFileName = pOfferFileInfoFrom.offerFileName; pOfferFileInfoTo.PhyFileName = pOfferFileInfoFrom.phyFileName; pOfferFileInfoTo.Loaded = pOfferFileInfoFrom.Loaded; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <OfferFileInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <OfferFileInfo>); } else { List <OfferFileInfo> list = new List <OfferFileInfo>(); OfferFileCollection collection = new OfferFileCollection(); Query qry = new Query(OfferFile.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (OfferFile offerFile in collection) { OfferFileInfo offerFileInfo = new OfferFileInfo(); LoadFromDAL(offerFileInfo, offerFile); list.Add(offerFileInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
//从后台获取数据 internal static void LoadFromDAL(OfferFileInfo pOfferFileInfo, OfferFile pOfferFile) { pOfferFileInfo.offerFileId = pOfferFile.OfferFileId; pOfferFileInfo.offerFileName = pOfferFile.OfferFileName; pOfferFileInfo.phyFileName = pOfferFile.PhyFileName; pOfferFileInfo.Loaded = true; }
//数据持久化 internal static void SaveToDb(OfferFileInfo pOfferFileInfo, OfferFile pOfferFile, bool pIsNew) { pOfferFile.OfferFileId = pOfferFileInfo.offerFileId; pOfferFile.OfferFileName = pOfferFileInfo.offerFileName; pOfferFile.PhyFileName = pOfferFileInfo.phyFileName; pOfferFile.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pOfferFile.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(OfferFileInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pOfferFileInfo.offerFileId = pOfferFile.OfferFileId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo))) { ResetCache(); } }
/// <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 <OfferFileInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <OfferFileInfo> list = new List <OfferFileInfo>(); Query q = OfferFile.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); OfferFileCollection collection = new OfferFileCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (OfferFile offerFile in collection) { OfferFileInfo offerFileInfo = new OfferFileInfo(); LoadFromDAL(offerFileInfo, offerFile); list.Add(offerFileInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <OfferFileInfo> pList, OfferFileCollection pCollection) { foreach (OfferFile offerFile in pCollection) { OfferFileInfo offerFileInfo = new OfferFileInfo(); LoadFromDAL(offerFileInfo, offerFile); pList.Add(offerFileInfo); } }
protected void btnDownLoad_Click(object sender, EventArgs e) { int opId = Convert.ToInt32(Request["OfferPriceId"].ToString()); OfferPriceInfo op = new OfferPriceInfo(opId); OfferFileInfo file = new OfferFileInfo(Convert.ToInt32(op.OfferFileId)); int fileid = Convert.ToInt32(file.OfferFileId); Response.Redirect("DownLoadFile.aspx?fileid="+fileid); }
protected void Page_Load(object sender, EventArgs e) { int fileid = Int32.Parse(Request.QueryString["fileid"].ToString());//��ȡ�ļ���ID OfferFileInfo file = new OfferFileInfo(fileid); string fileName = file.OfferFileName.ToString(); //��ȡ����·�� // string DeskPath = Convert.ToString(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); //string DeskPath = Server.MapPath("~\\Files\\File"); DownLoads(fileName); }
public OfferFileInfo GetOfferFileInfoById(int OfferFileId) { OfferFileInfo offerFileInfo = null;// try { offerFileInfo = new OfferFileInfo(OfferFileId); } catch (AppException) { return null; } return offerFileInfo; }
public OfferFileInfo GetOfferFileInfoById(int OfferFileId) { OfferFileInfo offerFileInfo = null; // try { offerFileInfo = new OfferFileInfo(OfferFileId); } catch (AppException) { return(null); } return(offerFileInfo); }
private void LoadFromId(int offerFileId) { if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo))) { OfferFileInfo offerFileInfo = Find(GetList(), offerFileId); if (offerFileInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(offerFileInfo, this); } else { OfferFile offerFile = new OfferFile(offerFileId); if (offerFile.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, offerFile); } }
public object SaveOfferFileInfo(OfferFileInfo offerFileInfo) { offerFileInfo.Save(); return offerFileInfo . OfferFileId; }
/// <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<OfferFileInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< OfferFileInfo> list = new List< OfferFileInfo>(); Query q = OfferFile .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); OfferFileCollection collection=new OfferFileCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (OfferFile offerFile in collection) { OfferFileInfo offerFileInfo = new OfferFileInfo(); LoadFromDAL(offerFileInfo, offerFile); list.Add(offerFileInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 复制为另一个对象 /// </summary> /// <param name="pIndustryTypeInfoTo"></param> public void CopyTo(OfferFileInfo pOfferFileInfoTo) { Copy(this, pOfferFileInfoTo); }
//从后台获取数据 internal static void LoadFromDAL(OfferFileInfo pOfferFileInfo, OfferFile pOfferFile) { pOfferFileInfo.offerFileId = pOfferFile.OfferFileId; pOfferFileInfo.offerFileName = pOfferFile.OfferFileName; pOfferFileInfo.phyFileName = pOfferFile.PhyFileName; pOfferFileInfo.Loaded=true; }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< OfferFileInfo> pList, OfferFileCollection pCollection) { foreach (OfferFile offerFile in pCollection) { OfferFileInfo offerFileInfo = new OfferFileInfo(); LoadFromDAL(offerFileInfo, offerFile ); pList.Add(offerFileInfo); } }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<OfferFileInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< OfferFileInfo>; } else { List< OfferFileInfo> list =new List< OfferFileInfo>(); OfferFileCollection collection=new OfferFileCollection(); Query qry = new Query(OfferFile.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(OfferFile offerFile in collection) { OfferFileInfo offerFileInfo= new OfferFileInfo(); LoadFromDAL(offerFileInfo,offerFile); list.Add(offerFileInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
public List <OfferFileInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { return(OfferFileInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount)); }
//数据持久化 internal static void SaveToDb(OfferFileInfo pOfferFileInfo, OfferFile pOfferFile,bool pIsNew) { pOfferFile.OfferFileId = pOfferFileInfo.offerFileId; pOfferFile.OfferFileName = pOfferFileInfo.offerFileName; pOfferFile.PhyFileName = pOfferFileInfo.phyFileName; pOfferFile.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pOfferFile.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(OfferFileInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pOfferFileInfo.offerFileId = pOfferFile.OfferFileId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferFileInfo))) { ResetCache(); } }
public void DeleteById(OfferFileInfo pOfferFileInfo) { OfferFileInfo offerFileInfo = new OfferFileInfo(pOfferFileInfo.OfferFileId); offerFileInfo.Delete(); }
protected void btnSave_Click(object sender, EventArgs e) { if (IsPageValid()) { try { EmployeeInfo em = (EmployeeInfo)Session["Employee"]; MainOfferPriceInfo mainop = new MainOfferPriceInfo(); mainop.Save(); int OpId = Convert.ToInt32(Request["OfferPriceId"].ToString()); OfferPriceInfo op = new OfferPriceInfo(OpId); op.MainOfferPriceId = mainop.MainOfferPriceId; if (ddlProject.SelectedValue != "") { op.MainProjectCreateId = Convert.ToInt32(ddlProject.SelectedValue); } if (ddlEmployee.SelectedValue != "") { op.EmployeeId = Convert.ToInt32(ddlEmployee.SelectedValue); } op.OfferPriceTypeId = Convert.ToInt32(rblType.SelectedValue); DateTime date = DateTime.Now; string strtoday = DateTime.Now.ToString("yyyyMMdd").Substring(2); op.Today = strtoday; op.SheetNum = txtSheetNum.Text.ToString(); op.FillTableDate = Convert.ToDateTime(txtFillTableDate.Text.ToString()); op.SectionView = txtSectionView.Text.ToString(); op.SheetNum = txtSheetNum.Text.ToString(); op.ProjectDes = txtProjectDes.Text.ToString(); op.MoneySum = txtMoneySum.Text.ToString(); op.BigMoney = txtBigMoney.Text.ToString(); op.ProductMoneySum = lblMoneySum.Text.ToString(); if (UpFile.HasFile == true) { string name = this.UpFile.FileName; int startindex = this.UpFile.FileName.LastIndexOf(@"\") + 1; string fileName = this.UpFile.FileName.Substring(startindex); string phyFileName = this.Server.MapPath(@"~\Files\" + "OfferPrice") + @"\" + fileName; this.UpFile.SaveAs(phyFileName); OfferFileInfo of = new OfferFileInfo(); of.OfferFileName = fileName;//�ļ��� of.PhyFileName = UpFile.PostedFile.FileName;//�����ļ�·�� of.Save(); op.OfferFileId = Convert.ToInt32(of.OfferFileId); } op.SendEmployeeName = em.EmployeeName; op.SendEmployeeId = em.EmployeeId; op.PreIsApply = 1; op.PreIsOver = 1; op.IsApply = 0; op.IsApprove = 0; op.IsApply1 = 0; op.IsApply2 = 0; op.IsOver1 = 0; op.IsOver2 = 0; //GridViewǶ���ж� op.IsMain = 1; op.IsMain1 = 1; op.IsMain2 = 1; op.IsMain3 = 1; op.IsNewCreate = 0; op.IsSignName = 0; op.Save(); if (UpFile.HasFile) { ////�ļ��ϴ���ַ��Ŀ¼������ͨ��IIS���豾������ΪFTP������ //string FileSaveUri = @"ftp://192.168.11.70/www/Files/OfferPrice/"; ////FTP�û������룬���DZ������û������� //string ftpUser = "******"; //string ftpPassWord = "******"; //SendFiles(FileSaveUri, ftpUser, ftpPassWord); this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/OfferPrice/" + UpFile.FileName)); } Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ӳɹ���');</script>"); ViewState["Isbtn"] = "1"; txtSheetNum.Text = SheetNums.SheetNumOfOP("BJTB", strtoday); gvProductInitBind(); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('���ʧ�ܣ�" + Ex.Message + "');", true); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (IsPageValid()) { try { int opid = Convert.ToInt32(Request["OfferPriceId"].ToString()); OfferPriceInfo pc = new OfferPriceInfo(opid); if (pc.IsNewCreate == 1) { pc.IsMain = 0; pc.IsMain1 = 0; pc.IsMain2 = 0; pc.IsMain3 = 0; OfferPriceInfo pcnew = new OfferPriceInfo(); pcnew.IsMain = 1; pcnew.IsMain1 = 1; pcnew.IsMain2 = 1; pcnew.IsMain3 = 1; pcnew.IsNewCreate = 0; pcnew.MainOfferPriceId = pc.MainOfferPriceId; pcnew.SendEmployeeId = pc.SendEmployeeId; pcnew.SendEmployeeName = pc.SendEmployeeName; pcnew.PreIsApply = 1; pcnew.PreIsOver = 1; pcnew.IsApply = 0; pcnew.IsApprove = 0; pcnew.IsApply1 = 0; pcnew.IsApply2 = 0; pcnew.IsOver1 = 0; pcnew.IsOver2 = 0; pcnew.IsSignName = 0; if (ddlProject.SelectedValue != "") { pcnew.MainProjectCreateId = Convert.ToInt32(ddlProject.SelectedValue); } if (ddlEmployee.SelectedValue != "") { pcnew.EmployeeId = Convert.ToInt32(ddlEmployee.SelectedValue); } DateTime date = DateTime.Now; string strtoday = DateTime.Now.ToString("yyyyMMdd").Substring(2); pcnew.Today = strtoday; if (UpFile.HasFile == true) { string name = this.UpFile.FileName; int startindex = this.UpFile.FileName.LastIndexOf(@"\") + 1; string fileName = this.UpFile.FileName.Substring(startindex); string phyFileName = this.Server.MapPath(@"~\Files\" + "OfferPrice") + @"\" + fileName; this.UpFile.SaveAs(phyFileName); if (pcnew.OfferFileId.ToString() == "") { OfferFileInfo of = new OfferFileInfo(); of.OfferFileName = fileName; of.PhyFileName = UpFile.PostedFile.FileName;//��ȡ�����ļ�·�� of.Save(); pcnew.OfferFileId = Convert.ToInt32(of.OfferFileId); } else { OfferFileInfo of = new OfferFileInfo(Convert.ToInt32(pcnew.OfferFileId)); of.OfferFileName = fileName;//�ļ����� of.PhyFileName = UpFile.PostedFile.FileName;//��ȡ�����ļ�·�� of.Save(); pcnew.OfferFileId = Convert.ToInt32(of.OfferFileId); } lblUrl.Text = UpFile.PostedFile.FileName;//�����ļ�·�� } if (UpFile.HasFile) { this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/OfferPrice/" + UpFile.FileName)); } pcnew.OfferPriceTypeId = Convert.ToInt32(rblType.SelectedValue); pcnew.FillTableDate = Convert.ToDateTime(txtFillTableDate.Text.ToString()); pcnew.SectionView = txtSectionView.Text.ToString(); pcnew.SheetNum = txtSheetNum.Text.ToString(); pcnew.ProjectDes = txtProjectDes.Text.ToString(); pcnew.MoneySum = txtMoneySum.Text.ToString(); pcnew.BigMoney = txtBigMoney.Text.ToString(); pcnew.ProductMoneySum = lblMoneySum.Text.ToString(); pcnew.Save(); pc.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('�����ɹ���');</script>"); } else { if (ddlProject.SelectedValue != "") { pc.MainProjectCreateId = Convert.ToInt32(ddlProject.SelectedValue); } if (ddlEmployee.SelectedValue != "") { pc.EmployeeId = Convert.ToInt32(ddlEmployee.SelectedValue); } if (UpFile.HasFile == true) { string name = this.UpFile.FileName; int startindex = this.UpFile.FileName.LastIndexOf(@"\") + 1; string fileName = this.UpFile.FileName.Substring(startindex); string phyFileName = this.Server.MapPath(@"~\Files\" + "OfferPrice") + @"\" + fileName; this.UpFile.SaveAs(phyFileName); if (pc.OfferFileId.ToString() == "") { OfferFileInfo of = new OfferFileInfo(); of.OfferFileName = fileName; of.PhyFileName = UpFile.PostedFile.FileName;//�����ļ�·�� of.Save(); pc.OfferFileId = Convert.ToInt32(of.OfferFileId); } else { OfferFileInfo of = new OfferFileInfo(Convert.ToInt32(pc.OfferFileId)); of.OfferFileName = fileName;//�ļ����� of.PhyFileName = UpFile.PostedFile.FileName;//�����ļ�·�� of.Save(); pc.OfferFileId = Convert.ToInt32(of.OfferFileId); } lblUrl.Text = UpFile.PostedFile.FileName; } if (UpFile.HasFile) { ////�ļ��ϴ���ַ��Ŀ¼������ͨ��IIS���豾������ΪFTP������ //string FileSaveUri = @"ftp://192.168.11.70/www/Files/OfferPrice/"; ////FTP�û������룬���DZ������û������� //string ftpUser = "******"; //string ftpPassWord = "******"; //SendFiles(FileSaveUri, ftpUser, ftpPassWord); this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/OfferPrice/" + UpFile.FileName)); } pc.FillTableDate = Convert.ToDateTime(txtFillTableDate.Text.ToString()); pc.SectionView = txtSectionView.Text.ToString(); pc.SheetNum = txtSheetNum.Text.ToString(); pc.ProjectDes = txtProjectDes.Text.ToString(); pc.OfferPriceTypeId = Convert.ToInt32(rblType.SelectedValue); pc.MoneySum = txtMoneySum.Text.ToString(); pc.BigMoney = txtBigMoney.Text.ToString(); pc.ProductMoneySum = lblMoneySum.Text.ToString(); pc.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('�༭�ɹ���');</script>"); } } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('���ʧ�ܣ�" + Ex.Message + "');", true); } } }
public List <OfferFileInfo> GetOfferFileInfoList() { return(OfferFileInfo.GetList()); }
protected void PageInit() { txtManagerView.ReadOnly = true; int opid = Convert.ToInt32(Request["OfferPriceId"].ToString()); OfferPriceInfo op = new OfferPriceInfo(opid); ddlProject.SelectedValue = op.MainProjectCreateId.ToString(); ddlEmployee.SelectedValue = op.EmployeeId.ToString(); txtFillTableDate.Text = op.FillTableDate.ToString(); txtManagerView.Text = op.MangerView.ToString(); txtSectionView.Text = op.SectionView.ToString(); txtSheetNum.Text = op.SheetNum.ToString(); txtProjectDes.Text = op.ProjectDes.ToString(); rblType.SelectedValue = op.OfferPriceTypeId.ToString(); lblMoneySum.Text = op.ProductMoneySum.ToString(); if (op.MoneySum != null) { txtMoneySum.Text = op.MoneySum.ToString(); } if (op.BigMoney != null) { txtBigMoney.Text = op.BigMoney.ToString(); } MainProjectCreateInfo project = new MainProjectCreateInfo(Convert.ToInt32(op.MainProjectCreateId)); lblProjectNum.Text = project.SheetNum.ToString(); if (op.OfferFileId != null) { OfferFileInfo of = new OfferFileInfo(Convert.ToInt32(op.OfferFileId)); lblUrl.Text = of.PhyFileName.ToString(); } }
public object SaveOfferFileInfo(OfferFileInfo offerFileInfo) { offerFileInfo.Save(); return(offerFileInfo.OfferFileId); }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(OfferFileInfo pOfferFileInfoFrom, OfferFileInfo pOfferFileInfoTo) { pOfferFileInfoTo.OfferFileId = pOfferFileInfoFrom.offerFileId; pOfferFileInfoTo.OfferFileName = pOfferFileInfoFrom.offerFileName; pOfferFileInfoTo.PhyFileName = pOfferFileInfoFrom.phyFileName; pOfferFileInfoTo.Loaded=pOfferFileInfoFrom.Loaded; }