public void WriteLog(MODEL.Log log) { Class.clsDB db = new Class.clsDB(); string sql = "Insert into log(create_by,content,ip_address,page) Values("; sql += "'" + log.create_by + "','" + log.content + "','" + log.ip + "','" + log.page + "')"; db.ExecuteNonQuery(sql); db.Close(); }
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); } }
public void WriteLog(MODEL.Log Log) { _BLL.WriteLog(Log); }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { String _userName, _password; _userName = UserName.Text.ToString(); _password = Password.Text.ToString(); String sql; DataTable dt; sql = "Select * from account where username='******' AND password='******'"; Class.clsDB conn = new Class.clsDB(); dt = conn.ExecuteDataTable(sql); if (dt.Rows.Count > 0) { Session["TITLE"] = dt.Rows[0]["title"].ToString(); Session["NAME"] = dt.Rows[0]["name"].ToString(); Session["SURNAME"] = dt.Rows[0]["surname"].ToString(); Session["LEVEL"] = dt.Rows[0]["level"].ToString(); Session["EMAIL"] = dt.Rows[0]["email"].ToString(); Session["PLACE_TYPE"] = dt.Rows[0]["place_type"].ToString(); string place_type = dt.Rows[0]["place_type"].ToString(); string Lev = dt.Rows[0]["level"].ToString(); Class.ClsModule obj = new Class.ClsModule(); string IP = obj.GetIPAddress(); string page = obj.getPageName(); MODEL.Log L = new MODEL.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Log in success."; L.create_by = Session["EMAIL"].ToString(); L.ip = IP; L.page = page; Log.WriteLog(L); switch (place_type) { case "A": Response.Redirect("~/PlaceA.aspx"); break; case "B": Response.Redirect("~/PlaceB.aspx"); break; case "C": Response.Redirect("~/PlaceC.aspx"); break; case "Z": Response.Redirect("~/PlaceZ.aspx"); break; } Response.Redirect("../Default.aspx"); } } }