Example #1
0
        public static void DepartmentBtnClick(string _SearchKey, TextBox txtBoxName, EventArgs e)
        {
            if (_SearchKey == "Escape")
            {
                _SearchKey = "";
            }
            IDepartment _objDepartment = new ClsDepartment();
            DataTable   dt             = _objDepartment.DepartmentLevel();

            if (dt.Rows.Count > 0)
            {
                DataRow[] result1 = dt.Select("Departmentlevel = 'I'");
                if (result1.Length > 0)
                {
                    PickList frmPickList = new PickList("DepartmentI", _SearchKey);
                    frmPickList.ShowDialog();
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        txtBoxName.Text = frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        txtBoxName.Tag  = Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        txtBoxName.Text = "";
                        txtBoxName.Tag  = "";
                    }
                    frmPickList.Dispose();
                }

                DataRow[] result2 = dt.Select("Departmentlevel = 'II'");
                if (result2.Length > 0)
                {
                    _SearchKey = "";
                    PickList frmPickList = new PickList("DepartmentII", _SearchKey);
                    frmPickList.ShowDialog();
                    txtBoxName.Text = txtBoxName.Text.Trim() + '|';
                    txtBoxName.Tag  = txtBoxName.Tag.ToString().Trim() + '|';
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        txtBoxName.Text = txtBoxName.Text + frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        txtBoxName.Tag  = txtBoxName.Tag.ToString() + Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        string[] _arr1 = txtBoxName.Text.Split('|');
                        string[] _arr2 = txtBoxName.Tag.ToString().Split('|');
                        txtBoxName.Text = _arr1[0] + "|";
                        txtBoxName.Tag  = _arr2[0] + "|";
                    }
                    frmPickList.Dispose();
                }
                else
                {
                    string[] _arr1 = txtBoxName.Text.Split('|');
                    string[] _arr2 = txtBoxName.Tag.ToString().Split('|');
                    txtBoxName.Text = _arr1[0] + "|";
                    txtBoxName.Tag  = _arr2[0] + "|";
                }

                DataRow[] result3 = dt.Select("Departmentlevel = 'III'");
                if (result3.Length > 0)
                {
                    _SearchKey = "";
                    PickList frmPickList = new PickList("DepartmentIII", _SearchKey);
                    frmPickList.ShowDialog();
                    txtBoxName.Text = txtBoxName.Text.Trim() + '|';
                    txtBoxName.Tag  = txtBoxName.Tag.ToString().Trim() + '|';
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        txtBoxName.Text = txtBoxName.Text + frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        txtBoxName.Tag  = txtBoxName.Tag.ToString() + Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        string[] _arr1 = txtBoxName.Text.Split('|');
                        string[] _arr2 = txtBoxName.Tag.ToString().Split('|');
                        txtBoxName.Text = _arr1[0] + "|" + _arr1[1] + "|";
                        txtBoxName.Tag  = _arr2[0] + "|" + _arr2[1] + "|";
                    }
                    frmPickList.Dispose();
                }
                else
                {
                    string[] _arr1 = txtBoxName.Text.Split('|');
                    string[] _arr2 = txtBoxName.Tag.ToString().Split('|');
                    txtBoxName.Text = _arr1[0] + "|" + _arr1[1] + "|";
                    txtBoxName.Tag  = _arr2[0] + "|" + _arr2[1] + "|";
                }

                DataRow[] result4 = dt.Select("Departmentlevel = 'IV'");
                if (result4.Length > 0)
                {
                    _SearchKey = "";
                    PickList frmPickList = new PickList("DepartmentIV", _SearchKey);
                    frmPickList.ShowDialog();
                    txtBoxName.Text = txtBoxName.Text.Trim() + '|';
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        txtBoxName.Text = txtBoxName.Text + frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        txtBoxName.Tag  = txtBoxName.Tag.ToString() + Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        string[] _arr1 = txtBoxName.Text.Split('|');
                        string[] _arr2 = txtBoxName.Tag.ToString().Split('|');
                        txtBoxName.Text = _arr1[0] + "|" + _arr1[1] + "|" + _arr1[2] + "|";
                        txtBoxName.Tag  = _arr2[0] + "|" + _arr2[1] + "|" + _arr2[2] + "|";
                    }
                    frmPickList.Dispose();
                }
                else
                {
                    string[] _arr1 = txtBoxName.Text.Split('|');
                    string[] _arr2 = txtBoxName.Tag.ToString().Split('|');
                    txtBoxName.Text = _arr1[0] + "|" + _arr1[1] + "|" + _arr1[2] + "|";
                    txtBoxName.Tag  = _arr2[0] + "|" + _arr2[1] + "|" + _arr2[2] + "|";
                }
            }
        }
Example #2
0
        public void Department()
        {
            if (searchKey == "Escape")
            {
                searchKey = "";
            }
            IDepartment _objDepartment = new ClsDepartment();
            DataTable   dt             = _objDepartment.DepartmentLevel();

            if (dt.Rows.Count > 0)
            {
                DataRow[] result1 = dt.Select("Departmentlevel = 'I'");
                if (result1.Length > 0)
                {
                    Common.PickList frmPickList = new Common.PickList("DepartmentI", searchKey);
                    frmPickList.ShowDialog();
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        Text = frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        Tag  = Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        Text = "";
                        Tag  = "";
                    }
                    frmPickList.Dispose();
                }

                DataRow[] result2 = dt.Select("Departmentlevel = 'II'");
                if (result2.Length > 0)
                {
                    searchKey = "";
                    Common.PickList frmPickList = new Common.PickList("DepartmentII", searchKey);
                    frmPickList.ShowDialog();
                    Text = Text.Trim() + '|';
                    Tag  = Tag.ToString().Trim() + '|';
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        Text = Text + frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        Tag  = Tag.ToString() + Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        string[] _arr1 = Text.Split('|');
                        string[] _arr2 = Tag.ToString().Split('|');
                        Text = _arr1[0] + "|";
                        Tag  = _arr2[0] + "|";
                    }
                    frmPickList.Dispose();
                }
                else
                {
                    string[] _arr1 = Text.Split('|');
                    string[] _arr2 = Tag.ToString().Split('|');
                    Text = _arr1[0] + "|";
                    Tag  = _arr2[0] + "|";
                }

                DataRow[] result3 = dt.Select("Departmentlevel = 'III'");
                if (result3.Length > 0)
                {
                    searchKey = "";
                    Common.PickList frmPickList = new Common.PickList("DepartmentIII", searchKey);
                    frmPickList.ShowDialog();
                    Text = Text.Trim() + '|';
                    Tag  = Tag.ToString().Trim() + '|';
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        Text = Text + frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        Tag  = Tag.ToString() + Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        string[] _arr1 = Text.Split('|');
                        string[] _arr2 = Tag.ToString().Split('|');
                        Text = _arr1[0] + "|" + _arr1[1] + "|";
                        Tag  = _arr2[0] + "|" + _arr2[1] + "|";
                    }
                    frmPickList.Dispose();
                }
                else
                {
                    string[] _arr1 = Text.Split('|');
                    string[] _arr2 = Tag.ToString().Split('|');
                    Text = _arr1[0] + "|" + _arr1[1] + "|";
                    Tag  = _arr2[0] + "|" + _arr2[1] + "|";
                }

                DataRow[] result4 = dt.Select("Departmentlevel = 'IV'");
                if (result4.Length > 0)
                {
                    searchKey = "";
                    Common.PickList frmPickList = new Common.PickList("DepartmentIV", searchKey);
                    frmPickList.ShowDialog();
                    Text = Text.Trim() + '|';
                    if (frmPickList.SelectedList.Count > 0)
                    {
                        Text = Text + frmPickList.SelectedList[0]["DepartmentDesc"].ToString().Trim();
                        Tag  = Tag.ToString() + Convert.ToInt32(frmPickList.SelectedList[0]["DepartmentId"].ToString().Trim());
                    }
                    else
                    {
                        string[] _arr1 = Text.Split('|');
                        string[] _arr2 = Tag.ToString().Split('|');
                        Text = _arr1[0] + "|" + _arr1[1] + "|" + _arr1[2] + "|";
                        Tag  = _arr2[0] + "|" + _arr2[1] + "|" + _arr2[2] + "|";
                    }
                    frmPickList.Dispose();
                }
                else
                {
                    string[] _arr1 = Text.Split('|');
                    string[] _arr2 = Tag.ToString().Split('|');
                    Text = _arr1[0] + "|" + _arr1[1] + "|" + _arr1[2] + "|";
                    Tag  = _arr2[0] + "|" + _arr2[1] + "|" + _arr2[2] + "|";
                }
            }
        }