Exemplo n.º 1
0
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        EasyDataProvide ContactBook = new EasyDataProvide("ContactBook");
        ContactBook.AddParameter("date", date.Text);
        ContactBook.AddParameter("grade_id", grade_id.SelectedValue);
        int i = ContactBook.GetRowCount("date=@date and grade_id=@grade_id");
        if (i > 0)
        {
            My.WebForm.doJavaScript("alert('該日該班級以建立聯絡簿,請重新選擇!');");
            return;
        }
        ContactBook.AddParameter("description", description.Text);
        string ContactBook_id=  ContactBook.InsertReturnValue();
        EasyDataProvide GradeStudent = new EasyDataProvide("GradeStudent");
        GradeStudent.AddParameter("grade_id",grade_id.SelectedValue);
        DataTable dtStudent = GradeStudent.GetData("grade_id=@grade_id");
        EasyDataProvide StudentContactBook = new EasyDataProvide("StudentContactBook");

        foreach (DataRow row in dtStudent.Rows)
        {
            StudentContactBook.AddParameter("people_id", row["student_id"].ToString());
            StudentContactBook.AddParameter("contactBook_id", ContactBook_id);
            StudentContactBook.Insert();
        }

        My.WebForm.doJavaScript("alert('新增成功');location.href='ContactBook_detail.aspx'");
    }
Exemplo n.º 2
0
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        //新增地址
        EasyDataProvide Address = new EasyDataProvide("Address");
        Address.AddParameter("city", Request["city"]);
        Address.AddParameter("division", Request["division"]);
        Address.AddParameter("zip", Request["zip"]);
        Address.AddParameter("address", address.Value);
        string addressID = Address.InsertReturnValue();

        //新增電話
        EasyDataProvide Telepone = new EasyDataProvide("Telephone");
        Telepone.AddParameter("areaCode", areaCode.Value);
        Telepone.AddParameter("numberCode", numberCode.Value);
        string telephoneID = Telepone.InsertReturnValue();

        //新增學校
        EasyDataProvide school = new EasyDataProvide("School");
        school.AddParameter("id",id.Text);
        int i = school.GetRowCount("id=@id");
        if(i>0)
        {
            My.WebForm.doJavaScript("alert('學校編號已經重複!')");
            return;
        }
        school.RemoveParameter("id");
        school.SetPlaceHolderFormQuest();

        school.AddParameter("address_id", addressID);
        school.AddParameter("telephone_id", telephoneID);
        school.Insert();
        My.WebForm.doJavaScript("alert('新增成功');location.href='School_List.aspx'");
    }
Exemplo n.º 3
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string ID = GridView1.DataKeys[e.RowIndex].Value.ToString();
        EasyDataProvide BookCase = new EasyDataProvide("BookCase");
        BookCase.AddParameter("tab_id", ID);
        int i = BookCase.GetRowCount("tab_id=@tab_id");
        if(i>0)
        {
            My.WebForm.doJavaScript("alert('該書籤目前正使用中!');");
            return;
        }

        _BookTab.DeleteById(ID);
        Show();
    }
    protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string ID = gvList.DataKeys[e.RowIndex].Value.ToString();

        //判斷預設課表是否有使用
        EasyDataProvide TimeTable = new EasyDataProvide("TimeTable");

        TimeTable.AddParameter("gradeCourseSubject_id", ID);
        int total = TimeTable.GetRowCount("gradeCourseSubject_id=@gradeCourseSubject_id");
        if (total > 0)
        {
            My.WebForm.doJavaScript("alert('預設課表已使用此課程!不可刪除!');");
            return;
        }

        EasyDataProvide GradeCourseSubject = new EasyDataProvide("GradeCourseSubject");

        GradeCourseSubject.DeleteById(ID);
        Response.Redirect(Request.Url.ToString());
    }
Exemplo n.º 5
0
    /// <summary>
    /// 利用班級編號取得該班學生人數
    /// </summary>
    /// <param name="gradeId">班級編號</param>
    /// <returns>班級學生人數</returns>
    public string GetGradeCountById(int gradeId)
    {
        EasyDataProvide GradeStudent = new EasyDataProvide("GradeStudent");

        GradeStudent.AddParameter("grade_id", gradeId.ToString());
        int count = GradeStudent.GetRowCount("grade_id=@grade_id");
        return count.ToString();
    }