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(); } }
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); }
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用户名密码,就是本机的用户名密码 //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); } } }
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用户名密码,就是本机的用户名密码 //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); } } }