예제 #1
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            String             store = txt_month.Text;
            String             dept  = txt_DeptNo.Text;
            String             month = txt_month.Text;
            String             year  = txt_Year.Text;
            Classificationcode c     = new Classificationcode(store, dept, month, year);

            Label1.Text = c.Result;
        }
예제 #2
0
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                try
                {
                    FileUpload1.SaveAs(Server.MapPath("~/uploads/") +
                                       FileUpload1.FileName);
                    String fileName = FileUpload1.PostedFile.FileName;
                    var    filePath = Path.Combine(Server.MapPath("~/uploads"), fileName);
                    FileUploadedLabel.Text = "File name: " +
                                             fileName + "<br>" +
                                             FileUpload1.PostedFile.ContentLength + " kb<br>" +
                                             "Content type: " + FileUpload1.PostedFile.ContentType;

                    if (!string.IsNullOrEmpty(filePath))
                    {
                        StringBuilder      strbuild = new StringBuilder();
                        Classificationcode c        = new Classificationcode();
                        using (StreamReader sr = new StreamReader(Path.Combine(Server.MapPath("~/uploads"), fileName)))
                        {
                            while (sr.Peek() >= 0)
                            {
                                strbuild.AppendFormat(sr.ReadLine());
                            }
                        }
                        Label1.Text = strbuild.ToString();
                        //c.ReadFileForBatch(strbuild);
                    }
                }
                catch (Exception ex)
                {
                    FileUploadedLabel.Text = "ERROR: " + ex.Message.ToString();
                }
            }
            else
            {
                FileUploadedLabel.Text = "You have not specified a file.";
            }
        }