private void Remove()
 {
     if (Index >= 0)
     {
         ClassDepartment.RemoveAt(Index);
     }
 }
        protected void btnSubmitDepartment_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertDepartmentID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสคณะ/หน่วยงานที่สังกัด หรือเทียบเท่า')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertDepartmentName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อคณะ/หน่วยงานที่สังกัด หรือเทียบเท่า')", true);
                return;
            }
            ClassDepartment d = new ClassDepartment();

            d.DEPARTMENT_ID   = txtInsertDepartmentID.Text;
            d.DEPARTMENT_NAME = txtInsertDepartmentName.Text;

            if (d.CheckUseDepartmentID())
            {
                d.InsertDepartment();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสคณะ/หน่วยงานที่สังกัด หรือเทียบเท่านี้ อยู่ในระบบแล้ว !')", true);
            }
        }
        private void Load()
        {
            string         pathToCsv      = "";
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Файл csv|*.csv";
            if (openFileDialog.ShowDialog() == true)
            {
                pathToCsv = openFileDialog.FileName;
            }
            if (File.Exists(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 department in ClassDepartment)
                        {
                            if (department.NameOfDepartment.Equals(parts[0].Trim(' ')))
                            {
                                exist = true;
                            }
                        }
                        if (!exist)
                        {
                            Faculty Faculty = null;
                            foreach (var faculty in facultities)
                            {
                                if (faculty.NameOfFaculty.Equals(parts[1].Trim(' ')))
                                {
                                    Faculty = faculty;
                                }
                            }
                            if (Faculty != null)
                            {
                                Department department = new Department
                                {
                                    NameOfDepartment = parts[0].Trim(' '),
                                    Faculty          = Faculty
                                };

                                if (RequestToDataBase.Instance.requestInsertIntoDepartment(department))
                                {
                                    ClassDepartment.Add(department);
                                }
                            }
                        }
                    }
                }
            }
        }
        void BindData1()
        {
            ClassDepartment d  = new ClassDepartment();
            DataTable       dt = d.GetDepartmentSearch(txtSearchDepartmentID.Text, txtSearchDepartmentName.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
        void BindData()
        {
            ClassDepartment d  = new ClassDepartment();
            DataTable       dt = d.GetDepartment("", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassDepartment d  = new ClassDepartment();
            DataTable       dt = d.GetDepartment("", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
 private void Remove()
 {
     if (Index >= 0)
     {
         if (RequestToDataBase.Instance.requestDeleteFromDepartment(ClassDepartment, Index))
         {
             ClassDepartment.RemoveAt(Index);
         }
     }
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtDepartmentIDEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDepartmentIDEdit");
            TextBox txtDepartmentNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDepartmentNameEdit");

            ClassDepartment d = new ClassDepartment(txtDepartmentIDEdit.Text, txtDepartmentNameEdit.Text);

            d.UpdateDepartment();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            string          id = GridView1.DataKeys[e.RowIndex].Value.ToString();
            ClassDepartment d  = new ClassDepartment();

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

            GridView1.EditIndex = -1;
            BindData1();
        }
        private void Add()
        {
            var context = new DepartmentVM(facultities.ToArray());
            var wind    = new NewDepartment()
            {
                DataContext = context
            };

            wind.ShowDialog();
            System.Console.WriteLine(context.Department != null);
            if (context.Department != null)
            {
                ClassDepartment.Add(context.Department);
            }
        }
 protected void btnSearchDepartment_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchDepartmentID.Text) && string.IsNullOrEmpty(txtSearchDepartmentName.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassDepartment d  = new ClassDepartment();
         DataTable       dt = d.GetDepartmentSearch(txtSearchDepartmentID.Text, txtSearchDepartmentName.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
        private void Add()
        {
            var context = new DepartmentVM(facultities.ToArray());
            var wind    = new NewDepartment()
            {
                DataContext = context
            };

            wind.ShowDialog();
            if (wind.DialogResult == true)
            {
                if (context.Department != null)
                {
                    if (RequestToDataBase.Instance.requestInsertIntoDepartment(context.Department))
                    {
                        ClassDepartment.Add(context.Department);
                    }
                }
            }
        }
Exemple #13
0
        public void Test_ClassDepartment_Method()
        {
            ClassDepartment cd = new ClassDepartment();

            Assert.IsTrue(cd.IsUnitTest);
        }