protected void btnok_Click(object sender, EventArgs e) { if (checkNull()) { if (FUCPic.FileBytes.Length > 0) { uploadPic(); } Entity.AssuranceInfo assuran = new Entity.AssuranceInfo(); assuran.Assurance_Name = txttitle.Text.ToString(); assuran.Date_End = txtdate.Text.ToString(); assuran.Assurance_Detail = editor.Content.ToString(); assuran.Assurance_Path = picturPath; assuran.Create_user = Session["userid"].ToString(); assuran.Update_user = Session["userid"].ToString(); bool insert = BLL.Assurance.insertAssurance(assuran); if (insert) { ShowMessageWeb("บันทึกข้อมูลเรียบร้อย! "); clearValue(); } else { ShowMessageWeb("บันทึกข้อมูลล้มเหลว! "); if (FUCPic.FileBytes.Length > 0) { System.IO.File.Delete(Server.MapPath(picturPath)); } } } }
protected void gvAssurance_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { Assurance_ID = gvAssurance.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString(); Entity.AssuranceInfo assurance = new Entity.AssuranceInfo(); assurance = BLL.Assurance.selectShowPopup(Assurance_ID.ToString()); txtPoPtitle.Text = assurance.Assurance_Name; editorPopup.Content = assurance.Assurance_Detail; pathImage = assurance.Assurance_Path.ToString(); imgID = pathImage; if (pathImage.Length > 0) { imgPopPic.ImageUrl = pathImage; imgPopPic.Visible = true; } else imgPopPic.Visible = false; string status = assurance.Assurance_status; if (status == "A") { ddlStatus.SelectedIndex = 0; } else { ddlStatus.SelectedIndex = 1; } txtPopdate.Text = assurance.Date_End; mdlpopup.Show(); } }
protected void btnsave_Click(object sender, EventArgs e) { Entity.AssuranceInfo update = new Entity.AssuranceInfo(); update.Assurance_ID = Assurance_ID.ToString(); update.Assurance_Name = txtPoPtitle.Text.ToString(); update.Assurance_Detail = editorPopup.Content.ToString(); update.Date_End = txtPopdate.Text.ToString(); if (FUCPic.FileBytes.Length > 0) { uploadPic(); update.Assurance_Path = picturPath; } else update.Assurance_Path = imgID.ToString(); if (ddlStatus.SelectedIndex == 0) { update.Assurance_status = "A"; } else { update.Assurance_status = "U"; } bool checkStatusUpdate = BLL.Assurance.UpdateAssurance(update); if (checkStatusUpdate) { if (FUCPic.FileBytes.Length > 0 && imgID.ToString().Length > 0) { System.IO.File.Delete(Server.MapPath(imgID.ToString())); } ShowMessageWeb("Update TrainningNews Success ! "); } else { ShowMessageWeb("Update TrainningNews Fail ! "); System.IO.File.Delete(Server.MapPath(picturPath)); } this.butImgSearch_Click(null, null); }
public static Entity.AssuranceInfo selectShowPopup(string id) { try { SqlDataReader dtReader; Entity.AssuranceInfo stdNews = new Entity.AssuranceInfo(); string sqlString = "SELECT Assurance_Name, Assurance_Detail, Assurance_Path, Assurance_Status, convert(datetime, Date_End, 103) as date FROM Assurance where Assurance_ID=@id"; ConnectDB connpath = new ConnectDB(); objConn = new SqlConnection(); objConn.ConnectionString = connpath.connectPath(); objConn.Open(); objCmd = new SqlCommand(sqlString, objConn); objCmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(id); dtReader = objCmd.ExecuteReader(); if (dtReader.Read()) { stdNews.Assurance_Name = dtReader["Assurance_Name"].ToString(); stdNews.Assurance_Detail = dtReader["Assurance_Detail"].ToString(); stdNews.Assurance_Path = dtReader["Assurance_Path"].ToString(); stdNews.Assurance_status = dtReader["Assurance_Status"].ToString(); stdNews.Date_End = dtReader["date"].ToString(); } dtReader.Close(); objConn.Close(); return stdNews; } catch (Exception) { return null; } }