private void metroButton1_Click(object sender, EventArgs e) { try { if (Validate()) { ClsModule faculty = new ClsModule(); faculty.Name = txtName.Text.ToUpper(); faculty.ShortName = txtShortname.Text.ToUpper(); faculty.Description = txtDescription.Text; faculty.Created_By = userId; faculty.newFaculty(); message = faculty.ErrorMessage + "Would you like to add a new faculty again"; DialogResult dialogResult = MessageBox.Show(message, "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Information); ClearEntries(); if (dialogResult == DialogResult.Yes) { ClearEntries(); } else { this.Close(); } } else { return; } } catch (Exception ex) { throw new ArgumentException(ex.ToString()); } }
void init() { ClsModule clsModule = new ClsModule(); clsModule.getAllFaculty(cmbFaculty); clsModule.getDepartmentByFaculty(cmbDepartment, facultyid); clsModule.getAllState(cmbState); clsModule.GetGender(cmbGender); }
private bool UploadMain() { if (FileUpload1.HasFile) { string folderPath = Server.MapPath("~/Pdf/"); //Check whether Directory (Folder) exists. if (!Directory.Exists(folderPath)) { //If Directory (Folder) does not exists. Create it. Directory.CreateDirectory(folderPath); } FileUpload fu = FileUpload1; String fileExtension = System.IO.Path.GetExtension(fu.FileName).ToLower(); String[] allowedExtensions = { ".pdf" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { try { ClsModule mdl = new ClsModule(); Doc.doc_id = mdl.getRuningNoDoc(); Doc.doc_name = fu.FileName; Doc.create_by = Session["NAME"].ToString(); Doc.secure_prepare = Session["EMAIL"].ToString(); Doc.attach_file_name = Doc.doc_id + ".zip"; Doc.content = Content.Text; Doc.pr_flag = 1; Doc.suplier_id = ddlCustomer.SelectedValue.ToString(); Doc.supplier_name = ddlCustomer.Text; Doc.comment = comment.Value; string s_newfilename = Doc.doc_id + fileExtension; fu.PostedFile.SaveAs(folderPath + s_newfilename); Thread.Sleep(3000); // Insert DB string ret; BLL.Upload _BLL = new BLL.Upload(); string temp; ret = _BLL.InsertDocument_step1(Doc); if (ret == "1") { Response.Write("1"); Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Upload success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); PdfToImage("", Doc.doc_id); } else { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Can not upload."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); } // lblMessage.Text = Path.GetFileName(FileUpload1.FileName) + " has been uploaded."; //imagepath = ImageSavedPath + s_newfilename; return(true); } catch (Exception ex) { Response.Write(ex.Message); Response.Write("File could not be uploaded."); Response.End(); // return false; } } else { Response.Write("Please upload pdf file only."); return(false); } } return(true); } else { Response.Write("<script>alert('โปรดเลือกเอกสารที่ต้องการ Approve ก่อน');</script>"); return(false); } }
private bool UploadMain() { if (FileUpload1.HasFile) { string folderPath = Server.MapPath("~/EXCEL/"); //Check whether Directory (Folder) exists. if (!Directory.Exists(folderPath)) { //If Directory (Folder) does not exists. Create it. Directory.CreateDirectory(folderPath); } FileUpload fu = FileUpload1; String fileExtension = System.IO.Path.GetExtension(fu.FileName).ToLower(); String[] allowedExtensions = { ".xlsx" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { try { string job_id; ClsModule mdl = new ClsModule(); job_id = mdl.getRuningNoDoc(); //Doc.doc_name = fu.FileName; //Doc.create_by = Session["NAME"].ToString(); //Doc.secure_prepare = Session["EMAIL"].ToString(); //Doc.attach_file_name = Doc.doc_id + ".zip"; //Doc.content = Content.Text; string s_newfilename = job_id + fileExtension; fu.PostedFile.SaveAs(folderPath + s_newfilename); ClsModule obj = new ClsModule(); MODEL.Log L = new MODEL.Log(); Helper.Utility Log = new Helper.Utility(); L.ip = obj.GetIPAddress(); L.page = obj.getPageName(); L.content = "Upload success."; L.create_by = ""; // Session["EMAIL"].ToString(); Log.WriteLog(L); ReadExcel(job_id); genBarcode(job_id); Response.Redirect("DataJob.aspx"); // lblMessage.Text = Path.GetFileName(FileUpload1.FileName) + " has been uploaded."; //imagepath = ImageSavedPath + s_newfilename; return(true); } catch (Exception ex) { Response.Write("File could not be uploaded." + ex.Message); return(false); } } else { Response.Write("Please upload xlsx file only."); return(false); } } return(true); } else { Response.Write("<script>alert('โปรดเลือกไฟล์ก่อน');</script>"); return(false); } }