Exemplo n.º 1
0
        protected void SchBox_Changed(object sender, EventArgs e)
        {
            string sch = SchBox.Text;

            try
            {
                SQLServerQuery ss     = new SQLServerQuery();
                DataTable      dt_pis = ss.LoadPIS(sch, "");

                if (dt_pis.Rows.Count > 0)
                {
                    string EmployeeID = dt_pis.Rows[0]["P_ID"].ToString();
                    string Name       = dt_pis.Rows[0]["name_fk"].ToString();
                    string posname    = dt_pis.Rows[0]["posname"].ToString();
                    string unitname   = dt_pis.Rows[0]["unitname"].ToString();
                    EmployeeIDLabel.Text = EmployeeID;
                    NameLabel.Text       = Name;
                    posnameLabel.Text    = posname;
                    unitnameLabel.Text   = unitname;
                    resultppl.Visible    = true;
                    SavePPL.Enabled      = true;
                }
                else
                {
                    string EmployeeID = "";
                    string Name       = "";
                    string posname    = "";
                    string unitname   = "";
                    EmployeeIDLabel.Text = EmployeeID;
                    NameLabel.Text       = Name;
                    posnameLabel.Text    = posname;
                    unitnameLabel.Text   = unitname;
                    SavePPL.Enabled      = false;
                    NoResult.Visible     = true;
                    errorlabel.Text      = "ไม่พบข้อมูล";
                }
            }
            catch {
                string EmployeeID = "";
                string Name       = "";
                string posname    = "";
                string unitname   = "";
                EmployeeIDLabel.Text = EmployeeID;
                NameLabel.Text       = Name;
                posnameLabel.Text    = posname;
                unitnameLabel.Text   = unitname;
                SavePPL.Enabled      = false;
                NoResult.Visible     = true;
                errorlabel.Text      = "ไม่พบข้อมูล";
            }
        }
Exemplo n.º 2
0
        private DataTable FindPttBInPis(string PTTB_str)
        {
            OracleQuery2   cc2    = new OracleQuery2();
            DataTable      dt     = cc2.LoadMobileInPTTB(PTTB_str);
            SQLServerQuery ss     = new SQLServerQuery();
            string         result = "";

            foreach (DataRow r in dt.Rows)
            {
                result = result + r["CODE"].ToString() + ",";
            }
            result = result.TrimEnd(',');
            result = result.TrimStart(',');

            DataTable dt_pis = ss.LoadPosecodeINPIS(result);
            DataTable dtppl  = new DataTable();

            dtppl.Columns.Add("MOBILE");
            dtppl.Columns.Add("DEPARTMENT_ID");
            dtppl.Columns.Add("EMPLOYEE_ID");
            dtppl.Columns.Add("NAME");
            dtppl.Columns.Add("COMPANY");
            dtppl.Columns.Add("GROUP_ID");
            if (dt != null && dt_pis != null && dt.Rows.Count > 0 && dt_pis.Rows.Count > 0)
            {
                var results = from table1 in dt.AsEnumerable()
                              join table2 in dt_pis.AsEnumerable() on table1["CODE"].ToString() equals table2["P_ID"].ToString()
                              select new
                {
                    code   = table1["CODE"].ToString(),
                    DEPART = table1["DEPARTMENT_ID"].ToString(),

                    mobile   = !string.IsNullOrEmpty(table1["mobile"].ToString()) ? table1["mobile"].ToString() : table2["mobile"].ToString(),
                    name     = table2["FULLNAMETH"].ToString(),
                    unit     = table2["unitname"].ToString(),
                    GROUP_ID = table1["GROUP_ID"].ToString(),
                };

                foreach (var item in results)
                {
                    dtppl.Rows.Add(item.mobile, item.DEPART, item.code, item.name, item.unit, item.GROUP_ID);
                }
            }
            return(dtppl);
        }
Exemplo n.º 3
0
        private void BindGrid()
        {
            OracleQuery2   cc2    = new OracleQuery2();
            DataTable      dt     = cc2.LoadAdmin();
            SQLServerQuery ss     = new SQLServerQuery();
            string         result = "";

            foreach (DataRow r in dt.Rows)
            {
                result = result + r["EMPLOYEE_ID"].ToString() + ",";
            }
            result = result.TrimEnd(',');
            DataTable dt_pis       = ss.LoadINPIS("", result);
            DataTable Final_result = new DataTable();

            Final_result.Columns.Add("EMPLOYEE_ID");
            Final_result.Columns.Add("FULLNAMETH");
            Final_result.Columns.Add("POSNAME");
            Final_result.Columns.Add("UNITNAME");
            Final_result.Columns.Add("IS_ADMIN");
            if (dt != null && dt_pis != null && dt.Rows.Count > 0 && dt_pis.Rows.Count > 0)
            {
                var results = from table1 in dt.AsEnumerable()
                              join table2 in dt_pis.AsEnumerable() on table1["EMPLOYEE_ID"].ToString() equals table2["P_ID"].ToString()
                              select new
                {
                    EMPLOYEE_ID = table1["EMPLOYEE_ID"].ToString(),
                    FULLNAMETH  = table2["FULLNAMETH"].ToString(),
                    POSNAME     = table2["POSNAME"].ToString(),
                    unitname    = table2["unitname"].ToString(),
                    is_admin    = table1["IS_ADMIN"].ToString() == "1"?"ADMIN":"USER"
                };

                foreach (var item in results)
                {
                    Final_result.Rows.Add(item.EMPLOYEE_ID, item.FULLNAMETH, item.POSNAME, item.unitname, item.is_admin);
                }
            }
            AdminGridView.DataSource = Final_result;
            AdminGridView.DataBind();
        }