public void Delete(int QuotationFileID) { QuotationFile _file = _context.QuotationFiles.Find(QuotationFileID); _file.Enabled = false; _context.SaveChanges(); }
public QuotationFileViewModel(QuotationFile File, string Supplier) { QuotationFileID = File.QuotationFileID; SupplierName = Supplier; UploadDate = File.CreateDate.ToString("yyyy-MM-dd"); FileLink = "/Purchase/GetQuotationFile?QuotationFileID=" + File.QuotationFileID; }
/// <summary> /// 客先担当選択.Model /// </summary> /// <param name="dataFile">ファイル情報</param> public SelectedStaff(DataFileInfo dataFile) { switch (dataFile.Kind) { case DataKind.Quotation: var file = new QuotationFile(dataFile); MakeClientStaffs(file.ClientName, file.ClientStaffs); _File = file; break; } }
protected void btnDownloadTemplate_Click(object sender, EventArgs e) { try { QuotationFile quotationFile = new QuotationFile(); quotationFile.CustomerCode = txtCustomerCode.Text; quotationFile.ForecastDate = DateTime.ParseExact(txtPeriod.Text.Insert(3, "01/"), formats, CultureInfo.InvariantCulture, DateTimeStyles.None); quotationFile.SysCreator = HttpContext.Current.User.Identity.Name; quotationFile.Export(); this.ltlMessage.Text = string.Empty; ReportViewer1.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new ReportServerNetworkCredentials(); ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.ServerReport.ReportServerUrl = new Uri((string)ViewState["ReportServerUrl"]); ReportViewer1.ServerReport.ReportPath = "/Forecast/ForecastTemplate"; ReportParameter[] myParam = { new ReportParameter("CustomerCode", quotationFile.CustomerCode) , new ReportParameter("ForecastDate",string.Format("{0:MM/dd/yyyy}", quotationFile.ForecastDate)) , new ReportParameter("SysCreator", quotationFile.SysCreator) }; ReportViewer1.ServerReport.SetParameters(myParam); ReportViewer1.ServerReport.Refresh(); string mimeType; string encoding; string extension; string[] streams; Warning[] warnings; byte[] bytes = ReportViewer1.ServerReport.Render("Excel", string.Empty, out mimeType, out encoding, out extension, out streams, out warnings); Response.Clear(); Response.ContentType = "application/excel"; Response.AddHeader("Content-disposition", string.Format("filename={0:yyyyMM}_{1}_Forecast.xls", quotationFile.ForecastDate, quotationFile.CustomerCode)); Response.AddHeader("Content-Length", bytes.Length.ToString()); Response.OutputStream.Write(bytes, 0, bytes.Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.Flush(); Response.Close(); } catch (Exception ex) { ltlMessage.Text = ex.Message.ToString().ToErrorMessageFormat(); } }
/// <summary> /// 終了処理 /// </summary> public override void Dispose() { base.Dispose(); if (PrintSummaries != null) { foreach (var summary in PrintSummaries) { summary.Dispose(); } PrintSummaries.Clear(); PrintSummaries = null; } File.Dispose(); File = null; }
public int Save(QuotationFile File) { if (File.QuotationFileID == 0) { _context.QuotationFiles.Add(File); } else { QuotationFile _dbEntry = _context.QuotationFiles.Find(File.QuotationFileID); if (_dbEntry != null) { _dbEntry.QuotationRequestID = File.QuotationRequestID; _dbEntry.SupplierID = File.SupplierID; _dbEntry.CreateDate = DateTime.Now; _dbEntry.Enabled = File.Enabled; _dbEntry.FileName = File.FileName; } } _context.SaveChanges(); return(File.QuotationFileID); }
/// <summary> /// 見積書改訂 /// </summary> public void RevisionQuotation() { if (Quotations.Count.Equals(0)) { Quotations.Add(new DataFileInfo(DataKind.Quotation, 0, DateTime.Now, 1, false)); } else { Quotations.Add(new DataFileInfo(DataKind.Quotation, Quotations[Quotations.Count - 1].Revision + 1, DateTime.Now, 1, false)); } SelectedQuotation = Quotations[Quotations.Count - 1]; var file = new QuotationFile(SelectedQuotation) { JobName = Name, QuoteNo = new DocumentNoFile().UpdateDocumentNo(DataKind.Quotation), ClientName = SelectedClient?.Name }; file.Save(); }
/// <summary> /// 見積書.Model /// </summary> /// <param name="dataFile">見積情報</param> public Quotation(DataFileInfo dataFile) { DataFile = dataFile; File = new QuotationFile(DataFile); }
private void ValidateAndUploadFile() { try { ViewState["xls"] = FileUpload1.FileBytes; IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(FileUpload1.PostedFile.InputStream); excelReader.IsFirstRowAsColumnNames = true; DataSet xls = excelReader.AsDataSet(); ViewState["Valid"] = true; DataTable CustomerFile = CreateTable(); List <string> colNames = new List <string>(columns.Values); List <string> colKeys = new List <string>(columns.Keys); Int32 ID = 1; CustomerFile = xls.Tables[sheet].AsEnumerable().Select(r => { var row = CustomerFile.NewRow(); row.ItemArray = new object[] { ID++, r[colNames[0]], r[colNames[1]], r[colNames[2]], r[colNames[3]], r[colNames[4]], r[colNames[5]], r[colNames[6]], r[colNames[7]], r[colNames[8]], r[colNames[9]] }; return(row); }).CopyToDataTable(); CustomerFile.AsEnumerable().Where(r => r[columns.FirstOrDefault(x => x.Value == "Customer Code").Key] == DBNull.Value | r[columns.FirstOrDefault(x => x.Value == "Ichikoh Part No").Key] == DBNull.Value).ToList().ForEach(r => r.Delete()); CustomerFile.AcceptChanges(); CustomerFile = CustomerFile.AsEnumerable().Where( r => r[colKeys[0]].ToString() != string.Empty | r[colKeys[1]].ToString() != string.Empty | r[colKeys[2]].ToString() != string.Empty | r[colKeys[3]].ToString() != string.Empty | r[colKeys[4]].ToString() != string.Empty | r[colKeys[5]].ToString() != string.Empty | r[colKeys[6]].ToString() != string.Empty | r[colKeys[7]].ToString() != string.Empty | r[colKeys[8]].ToString() != string.Empty | r[colKeys[9]].ToString() != string.Empty ).CopyToDataTable(); CustomerFile.TableName = "xml"; MemoryStream s = new MemoryStream(); CustomerFile.WriteXml(s, true); s.Seek(0, SeekOrigin.Begin); StreamReader sr = new StreamReader(s); string xml = sr.ReadToEnd(); sr.Close(); DataTable order = QuotationFile.Validate(xml); colNames.Add("ID"); colNames.Add("Customer CodeX"); colNames.Add("Ichikoh Part NoX"); gvSheet.DataKeyNames = colNames.ToArray(); gvSheet.DataSource = order; gvSheet.DataBind(); gvSheet.Visible = !(bool)ViewState["Valid"]; if ((bool)ViewState["Valid"]) { QuotationFile qf = new QuotationFile(); qf.Name = Path.GetFileName(FileUpload1.PostedFile.FileName); qf.ContentType = FileUpload1.PostedFile.ContentType; qf.Data = (byte[])ViewState["xls"]; order.TableName = "xml"; s = new MemoryStream(); order.WriteXml(s, true); s.Seek(0, SeekOrigin.Begin); sr = new StreamReader(s); qf.Xml = sr.ReadToEnd(); sr.Close(); qf.SysCreator = HttpContext.Current.User.Identity.Name; Int32 refID = qf.Import(); ltlMessage.Text = "<img src='../App_Themes/Default/images/listing/ico-accept.png' /> Successfuly uploaded file.".ToSuccessMessageFormat(); } } catch (Exception ex) { if (ex.Message.ToString().Contains("does not belong to table")) { ltlMessage.Text = "File is invalid. Please choose the customer forecast template or Excel file containing customer forecast orders.".ToErrorMessageFormat(); } else { ltlMessage.Text = string.Format("The file you are uploading is invalid. {0}.", ex.Message.ToString()).ToErrorMessageFormat(); } } }