Page 139 - ระบบสารสนเทศเพื่อการบริหารจัดการเอกสารอิเล็กทรอนิกส์ (e-Document)
P. 139

ห้องสมุดกรมพัฒนาที่ดิน
                                                                                                        ค- 26




                                  #region Check bValidExt (failure => terminate program)
                                  bValidExt = false;

                                  for (int i = 0; i < sValidExt.Length; i++)
                                  {
                                      sAlertInvalidFileType += " " + sValidExt[i];

                                      if (sValidExt[i] == sFileExt)
                                      {
                                          bValidExt = true;
                                      }
                                  }

                                  if (bValidExt == false)
                                  {
                                      return sAlertInvalidFileType;
                                  }
                                  #endregion

                                  #region Check file size (optional)
                                  if (upBrowse.PostedFile.ContentLength > 3145728)
                                  {
                                      return "ไม่สามารถแนบไฟล์ที่มีขนาดเกินกว่า 3 MB ได้";
                                  }
                                  #endregion
                                  #region Change name of uploaded file (optional)
                                  sFileName = sFilename + sFileExt;
                                  #endregion
                                  string sCurrentPath = Server.MapPath("~/" + sFolderName +
                  "/");

                                  if (upBrowse.HasFile)
                                  {
                                      sCurrentPath += sFileName;
                                      upBrowse.SaveAs(sCurrentPath);
                                      return "y" + sFileExt;
                                  }
                                  else
                                  {
                                      return sAlertFailure;
                                  }
                              }
                              catch (Exception ex)
                              {
                                  return "ไม่สามารถอัพโหลดไฟล์ได้ เนื่องจาก" + ex.Message;
                              }
                          }
                      }

                      protected void btnSave_Click(object sender, EventArgs e)
                      {
                          if (Request.Form["ddlBureau"] == "na")
                          {
                              Response.Write(ut.alert(" ระบุหน่วยงาน "));
                              return;
                          }

                          if (Request.Form["ddlPiority"] == "na")
   134   135   136   137   138   139   140   141   142   143   144