コード例 #1
0
 private void Remove()
 {
     if (Index >= 0)
     {
         ClassFaculty.RemoveAt(Index);
     }
 }
コード例 #2
0
        void BindData1()
        {
            ClassFaculty f  = new ClassFaculty();
            DataTable    dt = f.GetFacultySearch(txtSearchFacultyID.Text, txtSearchFacultyName.Text, txtSearchCampusID.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
コード例 #3
0
        void BindData()
        {
            ClassFaculty f  = new ClassFaculty();
            DataTable    dt = f.GetFaculty("", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
コード例 #4
0
 private void Remove()
 {
     if (Index >= 0)
     {
         if (RequestToDataBase.Instance.requestDeleteFromFaculty(ClassFaculty, Index))
         {
             ClassFaculty.RemoveAt(Index);
         }
     }
 }
コード例 #5
0
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassFaculty f  = new ClassFaculty();
            DataTable    dt = f.GetFaculty("", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
コード例 #6
0
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            int          id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
            ClassFaculty f  = new ClassFaculty();

            f.FACULTY_ID = id;
            f.DeleteFaculty();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
コード例 #7
0
        private void Add()
        {
            var context = new FacultyVM();
            var wind    = new NewFaculty()
            {
                DataContext = context
            };

            wind.ShowDialog();
            if (context.Faculty != null)
            {
                ClassFaculty.Add(context.Faculty);
            }
        }
コード例 #8
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtFacultyIDEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtFacultyIDEdit");
            TextBox txtFacultyNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtFacultyNameEdit");
            TextBox txtCampusIDEdit    = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCampusIDEdit");

            ClassFaculty f = new ClassFaculty(Convert.ToInt32(txtFacultyIDEdit.Text)
                                              , txtFacultyNameEdit.Text
                                              , Convert.ToInt32(txtCampusIDEdit.Text));

            f.UpdateFaculty();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }
コード例 #9
0
        private void Load()
        {
            string         pathToCsv      = "";
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Файл csv|*.csv";
            if (openFileDialog.ShowDialog() == true)
            {
                pathToCsv = openFileDialog.FileName;
            }
            if (!String.IsNullOrEmpty(pathToCsv))
            {
                char[] delimiters = new char[] { ';' };
                using (StreamReader reader = new StreamReader(pathToCsv, System.Text.Encoding.Default))
                {
                    while (true)
                    {
                        string line = reader.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        string[] parts = line.Split(delimiters);
                        bool     exist = false;
                        foreach (var faculty in ClassFaculty)
                        {
                            if (faculty.NameOfFaculty.Equals(parts[0].Trim(' ')))
                            {
                                exist = true;
                            }
                        }
                        if (!exist)
                        {
                            Faculty faculty = new Faculty {
                                NameOfFaculty = parts[0].Trim(' ')
                            };
                            if (RequestToDataBase.Instance.requestInsertIntoFaculty(faculty))
                            {
                                ClassFaculty.Add(faculty);
                            }
                        }
                    }
                    reader.Close();
                }
            }
        }
コード例 #10
0
        protected void btnSearchFaculty_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearchFacultyID.Text) && string.IsNullOrEmpty(txtSearchFacultyName.Text) && string.IsNullOrEmpty(txtSearchCampusID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);

                return;
            }
            else
            {
                ClassFaculty f  = new ClassFaculty();
                DataTable    dt = f.GetFacultySearch(txtSearchFacultyID.Text, txtSearchFacultyName.Text, txtSearchCampusID.Text);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                SetViewState(dt);
            }
        }
コード例 #11
0
        private void Add()
        {
            var context = new FacultyVM();
            var wind    = new NewFaculty()
            {
                DataContext = context
            };

            wind.ShowDialog();
            if (wind.DialogResult == true)
            {
                if (context.Faculty != null)
                {
                    if (RequestToDataBase.Instance.requestInsertIntoFaculty(context.Faculty))
                    {
                        ClassFaculty.Add(context.Faculty);
                    }
                }
            }
        }
コード例 #12
0
        protected void btnSubmitFaculty_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertFacultyID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสสำนัก / สถาบัน / คณะ')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertFacultyName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อสำนัก / สถาบัน / คณะ')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertCampusID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสวิทยาเขต')", true);
                return;
            }
            ClassFaculty f = new ClassFaculty();

            f.FACULTY_ID   = Convert.ToInt32(txtInsertFacultyID.Text);
            f.FACULTY_NAME = txtInsertFacultyName.Text;
            f.CAMPUS_ID    = Convert.ToInt32(txtInsertCampusID.Text);

            if (f.CheckUseFacultyID())
            {
                f.InsertFaculty();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสสำนัก / สถาบัน / คณะ นี้อยู่ในระบบแล้ว !')", true);
            }
        }