Page 272 - ระบบบริหารจัดการงบประมาณด้านเทคโนโลยีสารสนเทศและการสื่อสาร กรมพัฒนาที่ดิน
P. 272

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



                          try
                          {   string sFileName; //ชื่อไฟล์ abc.txt
                              string sFileExt; //ชนิดไฟล์ .txt

                              sFileName = Request.QueryString["FormID"] + fu01.FileName;
                              sFileExt = Path.GetExtension(sFileName).ToLower();
                              Boolean bValidExt = false;
                              for (int i = 0; i < sValidExt.Length; i++)

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

                                  sAlertInvalidFileType += " " + sValidExt[i];
                              }
                              if (bValidExt == false)
                                  return sAlertInvalidFileType;

                              if (fu01.PostedFile.ContentLength > iMaxFileSize)
                                  return sAlertSizeTooBig;
                              string sCurrentPath = Server.MapPath("~/" + sFolderName + "/");
                              sCurrentPath += sFileName;

                              fu01.SaveAs(sCurrentPath);
                              return sAlertSuccess + "|" + sFileName;
                          }

                          catch (Exception ex)
                          { return sAlertFail + ex.Message;
                          }
                      }
                      protected string checkVersion(string sItemStandardID, string sFiscalYear, string sVersion)

                      {   string sSql;
                          DbMgt table = new DbMgt(str);


                          sSql = "select count(*) from ActiveItemVersion where ItemStandardID = '" +
                  sItemStandardID + "' and FiscalYear = '" + sFiscalYear + "' and Version = " + sVersion;
                          if (table.exScalar(sSql) == "0")
                              return "f";

                          else
                              return "t";
                      }
   267   268   269   270   271   272   273   274   275   276   277