コード例 #1
0
ファイル: PhotoAlbum.cs プロジェクト: huaminglee/myyyyshop
 public List<Maticsoft.Model.CMS.PhotoAlbum> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.CMS.PhotoAlbum> list = new List<Maticsoft.Model.CMS.PhotoAlbum>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.CMS.PhotoAlbum item = new Maticsoft.Model.CMS.PhotoAlbum();
             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]["Description"] != null) && (dt.Rows[i]["Description"].ToString() != ""))
             {
                 item.Description = dt.Rows[i]["Description"].ToString();
             }
             if ((dt.Rows[i]["CoverPhoto"] != null) && (dt.Rows[i]["CoverPhoto"].ToString() != ""))
             {
                 item.CoverPhoto = new int?(int.Parse(dt.Rows[i]["CoverPhoto"].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]["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]["PVCount"] != null) && (dt.Rows[i]["PVCount"].ToString() != ""))
             {
                 item.PVCount = int.Parse(dt.Rows[i]["PVCount"].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 = int.Parse(dt.Rows[i]["Privacy"].ToString());
             }
             if ((dt.Rows[i]["LastUpdatedDate"] != null) && (dt.Rows[i]["LastUpdatedDate"].ToString() != ""))
             {
                 item.LastUpdatedDate = DateTime.Parse(dt.Rows[i]["LastUpdatedDate"].ToString());
             }
             list.Add(item);
         }
     }
     return list;
 }
コード例 #2
0
ファイル: Add.cs プロジェクト: huaminglee/myyyyshop
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.CMS.PhotoAlbum album = new Maticsoft.BLL.CMS.PhotoAlbum();
     if (string.IsNullOrWhiteSpace(this.txtAlbumName.Text))
     {
         MessageBox.ShowFailTip(this, CMSPhoto.ErrorAlbumNull);
     }
     else if (string.IsNullOrWhiteSpace(this.txtDescription.Text))
     {
         MessageBox.ShowFailTip(this, CMSPhoto.ErrorIntroductionNull);
     }
     else if (!PageValidate.IsNumber(this.txtSequence.Text))
     {
         MessageBox.ShowFailTip(this, CMSPhoto.ErrorOrderFormat);
     }
     else
     {
         string text = this.txtAlbumName.Text;
         string str2 = this.txtDescription.Text;
         int num = int.Parse(this.radlState.SelectedValue);
         int num2 = 0;
         int num3 = int.Parse(this.radlPrivacy.SelectedValue);
         Maticsoft.Model.CMS.PhotoAlbum album3 = new Maticsoft.Model.CMS.PhotoAlbum {
             AlbumName = text,
             Description = str2,
             CoverPhoto = 0,
             State = num,
             CreatedUserID = base.CurrentUser.UserID,
             CreatedDate = DateTime.Now,
             PVCount = num2,
             Sequence = album.GetMaxSequence(),
             Privacy = num3,
             LastUpdatedDate = DateTime.Now
         };
         Maticsoft.Model.CMS.PhotoAlbum model = album3;
         MessageBox.ResponseScript(this, "parent.location.href='/Admin/CMS/Photo/add.aspx?AlbumID=" + album.Add(model) + "'");
     }
 }