protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id = GridView1.DataKeys[e.RowIndex].Value.ToString(); GridViewRow row = GridView1.Rows[e.RowIndex]; if (row.Cells[0].Text == "角色") { if (id != "1") { EasyDataProvide RoleUserMapping = new EasyDataProvide("RoleUserMapping"); RoleUserMapping.AddParameter("roleID", id); RoleUserMapping.Delete("roleID=" + id); EasyDataProvide Role = new EasyDataProvide("Role"); Role.DeleteById(id); } else { My.WebForm.doJavaScript("alert('最高管理角色不可刪除!');"); } } else { _Member.DeleteById(id); } show(); }
protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e) { EasyDataProvide GradeStudent = new EasyDataProvide("GradeStudent"); string ID = gvList.DataKeys[e.RowIndex].Value.ToString(); GradeStudent.Delete(String.Format("student_id='{0}'", ID)); Show(); }
protected void Button1_Click(object sender, EventArgs e) { DataLayer dataLayer = new DataLayer(); DataRow row = dataLayer.Login(User.Identity.Name, Password.Text); if (row == null) { My.WebForm.doJavaScript("alert('密碼錯誤')"); return; } Person person = new Person(); EasyDataProvide StudentContactBookMessage = new EasyDataProvide("StudentContactBookMessage"); StudentContactBookMessage.AddParameter("studentContactBook_id", ViewState["studentContactBook_id"].ToString()); //先刪除 StudentContactBookMessage.AddParameter("studentContactBook_id", ViewState["studentContactBook_id"].ToString()); StudentContactBookMessage.Delete("studentContactBook_id=@studentContactBook_id and Role=2"); //後新增 StudentContactBookMessage.AddParameter("student_id", Request["people_id"]); StudentContactBookMessage.AddParameter("people_id", person.people_id); StudentContactBookMessage.AddParameter("Role", "2"); StudentContactBookMessage.AddParameter("article", txtArticle.Text); StudentContactBookMessage.AddParameter("contactBookDate", ViewState["date"].ToString()); StudentContactBookMessage.Insert(); EasyDataProvide StudentContactBook = new EasyDataProvide("StudentContactBook"); StudentContactBook.AddParameter("isSign", "true"); StudentContactBook.UpdateById(ViewState["studentContactBook_id"].ToString()); My.WebForm.doJavaScript(String.Format("alert('新增成功');location.href='ContactBook_ForParent.aspx?people_id={0}'", Request["people_id"])); }
protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e) { EasyDataProvide ParentChildren = new EasyDataProvide("ParentChildren"); string ID = gvList.DataKeys[e.RowIndex].Value.ToString(); ParentChildren.AddParameter("student_id", ID); ParentChildren.Delete("student_id=@student_id"); Show(); }
protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e) { string id = DataList1.DataKeys[e.Item.ItemIndex].ToString(); EasyDataProvide TimeTable = new EasyDataProvide("TimeTable"); TimeTable.AddParameter("grade_id", Request["id"]); TimeTable.AddParameter("sectionIndex_id", id); TimeTable.Delete("grade_id=@grade_id and sectionIndex_id=@sectionIndex_id"); Show(); }
protected void InsertButton_Click(object sender, EventArgs e) { if (_myPerson.Role == Person.LoginRole.Teacher) { bool flag = false; foreach (ListItem item in cblGrade.Items) { if (item.Selected) { flag = true; } } if (!flag) { My.WebForm.doJavaScript("alert('請選擇班級!!')"); return; } } _BookCase.SetPlaceHolderFormQuest(); _BookCase.UpdateById(Request["id"]); _AttachmentFile.SetPlaceHolderFormQuest(); string Path = GetMyPath(); string filePic = ""; if (fuPic.HasFile) { string PicExtension = fuPic.FileName.Split('.')[fuPic.FileName.Split('.').Length - 1]; //新檔案名稱 filePic = String.Format("{0:yyyyMMddhhmmsss}.{1}", DateTime.Now, PicExtension); fuPic.SaveAs(String.Format("{0}/{1}", Path, filePic)); _AttachmentFile.AddParameter("coverPicName", filePic); } _AttachmentFile.UpdateById(ViewState["file_id"].ToString()); EasyDataProvide BookCaseGrade = new EasyDataProvide("BookCaseGrade"); if (_myPerson.Role == Person.LoginRole.Teacher) { BookCaseGrade.AddParameter("bookCase_id", Request["id"]); BookCaseGrade.Delete("bookCase_id=@bookCase_id"); foreach (ListItem item in cblGrade.Items) { if (item.Selected) { BookCaseGrade.AddParameter("bookCase_id", Request["id"]); BookCaseGrade.AddParameter("grade_id", item.Value); BookCaseGrade.Insert(); } } } My.WebForm.doJavaScript("alert('修改成功');location.href='BookCase_List.aspx'"); }
protected void InsertButton_Click(object sender, EventArgs e) { Person person = new Person(); EasyDataProvide StudentContactBookMessage = new EasyDataProvide("StudentContactBookMessage"); //先刪除 StudentContactBookMessage.AddParameter("studentContactBook_id", ViewState["contactBook_id"].ToString()); StudentContactBookMessage.Delete("studentContactBook_id=@studentContactBook_id"); //後新增 StudentContactBookMessage.AddParameter("student_id", Request["people_id"]); StudentContactBookMessage.AddParameter("people_id", person.people_id); StudentContactBookMessage.AddParameter("Role", "0"); StudentContactBookMessage.AddParameter("article", article.Text); StudentContactBookMessage.AddParameter("contactBookDate", ViewState["date"].ToString()); StudentContactBookMessage.Insert(); My.WebForm.doJavaScript("alert('新增成功');location.href='ContactBook_detail.aspx'"); }
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e) { //更新到資料庫 DropDownList ddlGradeCourseSubject = (DropDownList)e.Item.FindControl("ddlGradeCourseSubject"); if (ddlGradeCourseSubject.Items.Count > 0) { string id = DataList1.DataKeys[e.Item.ItemIndex].ToString(); EasyDataProvide TimeTable = new EasyDataProvide("TimeTable"); TimeTable.AddParameter("grade_id", Request["id"]); TimeTable.AddParameter("sectionIndex_id", id); TimeTable.Delete("grade_id=@grade_id and sectionIndex_id=@sectionIndex_id"); TimeTable.AddParameter("gradeCourseSubject_id", ddlGradeCourseSubject.SelectedValue); TimeTable.Insert(); } DataList1.EditItemIndex = -1; Show(); }