protected void btnSave_Click(object sender, EventArgs e) { string str = this.txtAlbumName.Text.Trim(); string str2 = this.hfCoverVideo.Value.Trim(); string str3 = this.txtDescription.Text.Trim(); string selectedValue = this.radlState.SelectedValue; string inputData = this.txtSequence.Text.Trim(); string str6 = this.radlPrivacy.SelectedValue; if (string.IsNullOrWhiteSpace(str)) { MessageBox.ShowFailTip(this, CMSVideo.ErrorVideoNameNull); } else if (!PageValidate.IsNumber(selectedValue)) { MessageBox.ShowFailTip(this, CMSVideo.ErrorStartFormat); } else if ((inputData.Length > 0) && !PageValidate.IsNumber(inputData)) { MessageBox.ShowFailTip(this, CMSVideo.ErrorOrderFormat); } else if (!PageValidate.IsNumber(str6)) { MessageBox.ShowFailTip(this, CMSVideo.ErrorPrivacyFormed); } else { if (!string.IsNullOrWhiteSpace(str2)) { string str7 = "T_" + str2; string path = HttpContext.Current.Server.MapPath(Maticsoft.Components.MvcApplication.UploadFolder + str7); if (File.Exists(path)) { ImageTools.MakeThumbnail(HttpContext.Current.Server.MapPath(Maticsoft.Components.MvcApplication.UploadFolder + str2), path, 120, 120, MakeThumbnailMode.Auto, InterpolationMode.High, SmoothingMode.HighQuality); str2 = str7; } } Maticsoft.Model.CMS.VideoAlbum model = new Maticsoft.Model.CMS.VideoAlbum { AlbumName = str, CoverVideo = str2, Description = str3, CreatedUserID = base.CurrentUser.UserID, CreatedDate = DateTime.Now, LastUpdateUserID = new int?(base.CurrentUser.UserID), LastUpdatedDate = new DateTime?(DateTime.Now), State = Globals.SafeInt(selectedValue, 2), Sequence = Globals.SafeInt(inputData, 1), Privacy = new int?(Globals.SafeInt(str6, 0)), PvCount = 0 }; if (this.bll.Add(model) > 0) { MessageBox.ResponseScript(this, "parent.location.href='list.aspx'"); } else { MessageBox.ShowFailTip(this, Site.TooltipSaveError); } } }
public List<Maticsoft.Model.CMS.VideoAlbum> DataTableToList(DataTable dt) { List<Maticsoft.Model.CMS.VideoAlbum> list = new List<Maticsoft.Model.CMS.VideoAlbum>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Maticsoft.Model.CMS.VideoAlbum item = new Maticsoft.Model.CMS.VideoAlbum(); if ((dt.Rows[i]["AlbumID"] != null) && (dt.Rows[i]["AlbumID"].ToString() != "")) { item.AlbumID = int.Parse(dt.Rows[i]["AlbumID"].ToString()); } if ((dt.Rows[i]["AlbumName"] != null) && (dt.Rows[i]["AlbumName"].ToString() != "")) { item.AlbumName = dt.Rows[i]["AlbumName"].ToString(); } if ((dt.Rows[i]["CoverVideo"] != null) && (dt.Rows[i]["CoverVideo"].ToString() != "")) { item.CoverVideo = dt.Rows[i]["CoverVideo"].ToString(); } if ((dt.Rows[i]["Description"] != null) && (dt.Rows[i]["Description"].ToString() != "")) { item.Description = dt.Rows[i]["Description"].ToString(); } if ((dt.Rows[i]["CreatedUserID"] != null) && (dt.Rows[i]["CreatedUserID"].ToString() != "")) { item.CreatedUserID = int.Parse(dt.Rows[i]["CreatedUserID"].ToString()); } if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != "")) { item.CreatedDate = DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString()); } if ((dt.Rows[i]["LastUpdateUserID"] != null) && (dt.Rows[i]["LastUpdateUserID"].ToString() != "")) { item.LastUpdateUserID = new int?(int.Parse(dt.Rows[i]["LastUpdateUserID"].ToString())); } if ((dt.Rows[i]["LastUpdatedDate"] != null) && (dt.Rows[i]["LastUpdatedDate"].ToString() != "")) { item.LastUpdatedDate = new DateTime?(DateTime.Parse(dt.Rows[i]["LastUpdatedDate"].ToString())); } if ((dt.Rows[i]["State"] != null) && (dt.Rows[i]["State"].ToString() != "")) { item.State = int.Parse(dt.Rows[i]["State"].ToString()); } if ((dt.Rows[i]["Sequence"] != null) && (dt.Rows[i]["Sequence"].ToString() != "")) { item.Sequence = int.Parse(dt.Rows[i]["Sequence"].ToString()); } if ((dt.Rows[i]["Privacy"] != null) && (dt.Rows[i]["Privacy"].ToString() != "")) { item.Privacy = new int?(int.Parse(dt.Rows[i]["Privacy"].ToString())); } if ((dt.Rows[i]["PvCount"] != null) && (dt.Rows[i]["PvCount"].ToString() != "")) { item.PvCount = int.Parse(dt.Rows[i]["PvCount"].ToString()); } list.Add(item); } } return list; }
public Maticsoft.Model.CMS.VideoAlbum GetModelEx(int AlbumID) { StringBuilder builder = new StringBuilder(); builder.Append(" SELECT top 1 * FROM View_VideoAlbum "); builder.Append(" where AlbumID=@AlbumID "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@AlbumID", SqlDbType.Int, 4) }; cmdParms[0].Value = AlbumID; Maticsoft.Model.CMS.VideoAlbum album = new Maticsoft.Model.CMS.VideoAlbum(); DataSet ds = DbHelperSQL.Query(builder.ToString(), cmdParms); if (DataSetTools.DataSetIsNull(ds)) { return null; } if (ds.Tables[0].Rows.Count <= 0) { return null; } if ((ds.Tables[0].Rows[0]["AlbumID"] != null) && (ds.Tables[0].Rows[0]["AlbumID"].ToString() != "")) { album.AlbumID = int.Parse(ds.Tables[0].Rows[0]["AlbumID"].ToString()); } if ((ds.Tables[0].Rows[0]["AlbumName"] != null) && (ds.Tables[0].Rows[0]["AlbumName"].ToString() != "")) { album.AlbumName = ds.Tables[0].Rows[0]["AlbumName"].ToString(); } if ((ds.Tables[0].Rows[0]["CoverVideo"] != null) && (ds.Tables[0].Rows[0]["CoverVideo"].ToString() != "")) { album.CoverVideo = ds.Tables[0].Rows[0]["CoverVideo"].ToString(); } if ((ds.Tables[0].Rows[0]["Description"] != null) && (ds.Tables[0].Rows[0]["Description"].ToString() != "")) { album.Description = ds.Tables[0].Rows[0]["Description"].ToString(); } if ((ds.Tables[0].Rows[0]["CreatedUserID"] != null) && (ds.Tables[0].Rows[0]["CreatedUserID"].ToString() != "")) { album.CreatedUserID = int.Parse(ds.Tables[0].Rows[0]["CreatedUserID"].ToString()); } if ((ds.Tables[0].Rows[0]["CreatedUserName"] != null) && (ds.Tables[0].Rows[0]["CreatedUserName"].ToString() != "")) { album.CreatedUserName = ds.Tables[0].Rows[0]["CreatedUserName"].ToString(); } if ((ds.Tables[0].Rows[0]["CreatedDate"] != null) && (ds.Tables[0].Rows[0]["CreatedDate"].ToString() != "")) { album.CreatedDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedDate"].ToString()); } if ((ds.Tables[0].Rows[0]["LastUpdateUserID"] != null) && (ds.Tables[0].Rows[0]["LastUpdateUserID"].ToString() != "")) { album.LastUpdateUserID = new int?(int.Parse(ds.Tables[0].Rows[0]["LastUpdateUserID"].ToString())); } if ((ds.Tables[0].Rows[0]["LastUpdateUserName"] != null) && (ds.Tables[0].Rows[0]["CreatedUserName"].ToString() != "")) { album.LastUpdateUserName = ds.Tables[0].Rows[0]["LastUpdateUserName"].ToString(); } if ((ds.Tables[0].Rows[0]["LastUpdatedDate"] != null) && (ds.Tables[0].Rows[0]["LastUpdatedDate"].ToString() != "")) { album.LastUpdatedDate = new DateTime?(DateTime.Parse(ds.Tables[0].Rows[0]["LastUpdatedDate"].ToString())); } if ((ds.Tables[0].Rows[0]["State"] != null) && (ds.Tables[0].Rows[0]["State"].ToString() != "")) { album.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if ((ds.Tables[0].Rows[0]["Sequence"] != null) && (ds.Tables[0].Rows[0]["Sequence"].ToString() != "")) { album.Sequence = int.Parse(ds.Tables[0].Rows[0]["Sequence"].ToString()); } if ((ds.Tables[0].Rows[0]["Privacy"] != null) && (ds.Tables[0].Rows[0]["Privacy"].ToString() != "")) { album.Privacy = new int?(int.Parse(ds.Tables[0].Rows[0]["Privacy"].ToString())); } if ((ds.Tables[0].Rows[0]["PvCount"] != null) && (ds.Tables[0].Rows[0]["PvCount"].ToString() != "")) { album.PvCount = int.Parse(ds.Tables[0].Rows[0]["PvCount"].ToString()); } return album; }