2 using System
.Collections
.Generic
;
6 using System
.Web
.UI
.WebControls
;
7 using PumpkinHouseDatabase
;
8 using PumpkinHouse
.Utils
;
11 namespace PumpkinHouse
.Admin
13 public partial class PictureManagement
: System
.Web
.UI
.Page
16 protected void Page_Load(object sender
, EventArgs e
)
20 DateTime start
= DateTime
.Parse("2012/1/1");
21 DateTime today
= DateTime
.Now
;
23 CalendarStart
.SelectedDate
= start
;
25 CalendarEnd
.SelectedDate
= today
;
31 protected void BindDataSource()
33 // SqlDataSource1.SelectCommand =
34 // @"SELECT [Id], [Description], [Upload_Time], [Tags], u.[Username], [Image_Filename], [Image_File_Ext], [Nick_Name], [On_Top]
35 // FROM [DB_Picture] d, [DB_User] u
36 // where d.Username = u.Username ";
37 // SqlDataSource1.UpdateCommandType = SqlDataSourceCommandType.Text;
38 // SqlDataSource1.UpdateCommand = "Update DB_Picture set Description = @Description, Tags = @Tags, On_Top = @On_Top where Id = @Id";
40 // if (!string.IsNullOrEmpty(textNickName.Text))
42 // string name = textNickName.Text.Trim();
43 // SqlDataSource1.SelectCommand += " and u.Nick_Name = '" + name + "'";
45 // if (!string.IsNullOrEmpty(textPictureId.Text))
48 // bool success = long.TryParse(textPictureId.Text, out id);
51 // SqlDataSource1.SelectCommand += " and d.Id = " + id;
55 SqlDataSource1
.FilterExpression
= string.Format("(Nick_Name LIKE '{0}' AND Collect_Time >= '{1}' and Collect_Time <= '{2}') ",
56 textNickName
.Text
, CalendarStart
.SelectedDate
.ToString("yyyy-MM-dd"), CalendarEnd
.SelectedDate
.AddDays(1).ToString("yyyy-MM-dd"));
58 if (!string.IsNullOrWhiteSpace(textPictureId
.Text
))
60 SqlDataSource1
.FilterExpression
+= "and Id = " + textPictureId
.Text
;
68 protected void btnFilter_Click(object sender
, EventArgs e
)
70 if (string.IsNullOrEmpty(textNickName
.Text
))
72 textNickName
.Text
= "%";
77 protected void OnUpdating(object sender
, GridViewUpdateEventArgs e
)
79 using (DataUtils utils
= new DataUtils())
81 long id
= (long)e
.Keys
[0];
82 DB_Collection2 pic
= utils
.FindCollection2(id
);
85 pic
.Tags
= e
.NewValues
["Tags"] as string;
86 pic
.Description
= e
.NewValues
["Description"] as string;
87 if (e
.NewValues
["On_Top"].Equals("1") && (e
.OldValues
["On_Top"] == null || e
.OldValues
["On_Top"].Equals("0")))
90 pic
.On_Top_Update_Time
= DateTime
.Now
;
92 if (e
.NewValues
["On_Top"].Equals("0") && e
.OldValues
["On_Top"].Equals("1"))
95 pic
.On_Top_Update_Time
= null;
103 protected void OnDelete(object sender
, GridViewDeleteEventArgs e
)
107 long id
= (long)e
.Keys
[0];
108 using (DataUtils utils
= new DataUtils())
110 DB_Collection2 col
= utils
.FindCollection2(id
);
113 Operation
.DeleteCollection(utils
, col
);
120 protected void OnDateChanged(object sender
, EventArgs e
)
125 protected void PageIndexChanged(object sender
, EventArgs e
)
130 protected void Sorted(object sender
, EventArgs e
)
135 protected void OnEditing(object sender
, GridViewEditEventArgs e
)
140 protected void SqlDataSource1_Selected(object sender
, SqlDataSourceStatusEventArgs e
)
142 lblCount
.Text
= e
.AffectedRows
.ToString();
145 protected void deleteSelected_Click(object sender
, EventArgs e
)
147 using (DataUtils utils
= new DataUtils())
149 for (int i
= 0; i
<= GridView1
.Rows
.Count
- 1; i
++)
151 CheckBox CheckBox
= (CheckBox
)GridView1
.Rows
[i
].FindControl("CheckBox");
152 if (CheckBox
.Checked
)
154 long id
= long.Parse(GridView1
.Rows
[i
].Cells
[2].Text
);
155 DB_Collection2 col2
= utils
.FindCollection2(id
);
156 Operation
.DeleteCollection(utils
, col2
);
164 protected void selectAll_CheckedChanged(object sender
, EventArgs e
)
166 for (int i
= 0; i
<= GridView1
.Rows
.Count
- 1; i
++)
168 CheckBox CheckBox
= (CheckBox
)GridView1
.Rows
[i
].FindControl("CheckBox");
169 if (this.selectAll
.Checked
== true)
171 CheckBox
.Checked
= true;
175 CheckBox
.Checked
= false;