private void SetDataNews(string refNo) { try { BLNews blNews = new BLNews(); DataSet ds = blNews.GetNews("", "", "", "", "", refNo); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { txtRefNo.InnerText = refNo; txtNewsName.Text = dr["SUBJECT"].ToString(); ddlUserType.Items.FindByText(dr["USER_TYPE_NAME"].ToString()).Selected = true; rdStatus.SelectedValue = dr["IS_ACTIVE"].ToString(); //.Items.FindByValue(dr["STATUS"].ToString()).Selected = true; if (!String.IsNullOrEmpty(dr["DATE_FROM"].ToString())) { DateTime dt = Convert.ToDateTime(dr["DATE_FROM"].ToString()); txtStartDate.Value = dt.Day.ToString() + '/' + dt.Month.ToString() + '/' + dt.Year.ToString(); } if (!String.IsNullOrEmpty(dr["DATE_TO"].ToString())) { DateTime dt = Convert.ToDateTime(dr["DATE_TO"].ToString()); txtEndDate.Value = dt.Day.ToString() + '/' + dt.Month.ToString() + '/' + dt.Year.ToString(); } hdEditor.Value = dr["DETAIL"].ToString(); if (!String.IsNullOrEmpty(dr["THUMBNAIL"].ToString())) { byte[] bytes = (byte[])dr["THUMBNAIL"]; string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); imgPreview.Src = "data:image/jpg;base64," + base64String; hdHasImage.Value = "Y"; } } } } } catch (Exception ex) { throw ex; } }
public static string GetNews(string newsName, string newsStartDate, string newsEndDate, string userType, string status, string refNo) { string result = ""; try { BLNews blNews = new BLNews(); DataSet ds = new DataSet(); Utility utility = new Utility(); ds = blNews.GetNews(newsName, newsStartDate, newsEndDate, userType, status, refNo); result = utility.DataTableToJSONWithJavaScriptSerializer(ds.Tables[0]); } catch (Exception ex) { throw ex; } return(result); }
public static string GetRefRunningNo() { DataSet ds = new DataSet(); BLNews blNews = new BLNews(); string result = ""; Utility utility = new Utility(); try { ds = blNews.GetRefRunningNo(); result = utility.DataTableToJSONWithJavaScriptSerializer(ds.Tables[0]); } catch (Exception ex) { //throw ex; } return(result); }
public static string UpdateNews(string refNo, string newsName, string newsStartDate, string newsEndDate, string userType, string status, string fileName, string updateBy, string detail) { string str = ""; try { BLNews blNews = new BLNews(); bool result = false; DataTable dt = new DataTable(); Utility utility = new Utility(); byte[] data = null; if (!String.IsNullOrEmpty(fileName)) { string filePath = System.Web.Hosting.HostingEnvironment.MapPath( "~/Uploads/Thumbnail/" + fileName); data = System.IO.File.ReadAllBytes(filePath); } result = blNews.UpdateNews(refNo, newsName, newsStartDate, newsEndDate, userType, status, data, updateBy, detail); dt.Columns.Add("result"); dt.Rows.Add("false"); if (result) { dt.Rows[0]["result"] = "true"; } str = utility.DataTableToJSONWithJavaScriptSerializer(dt); } catch (Exception ex) { //throw ex; } return(str); }