示例#1
0
        private void btnBoss_Browse_Click(object sender, EventArgs e)
        {
            string time  = "";
            string sql   = "";
            string year  = "";
            string month = "";

            string sql_0   = String.Format("select count(*) from t_employee where eno ='{0}'", Eno);
            int    count_0 = (int)DAO.ExecuteScalar(sql_0);

            if (count_0 <= 0)
            {
                dgvPersonalSalary.Columns.Clear();
                MessageBox.Show("请输入正确的编号!");
                return;
            }
            else
            {
                if (level == 0)//按年
                {
                    if (cmbYear.SelectedIndex == -1)
                    {
                        dgvPersonalSalary.Columns.Clear();
                        MessageBox.Show("请选择时间!");
                        return;
                    }
                    else
                    {
                        year  = this.cmbYear.SelectedItem.ToString().Trim();
                        time += year;
                    }
                }
                else
                {
                    if (cmbMonth.SelectedIndex == -1 || cmbYear.SelectedIndex == -1)
                    {
                        dgvPersonalSalary.Columns.Clear();
                        MessageBox.Show("请选择时间!");
                        return;
                    }
                    else
                    {
                        year  = this.cmbYear.SelectedItem.ToString().Trim();
                        month = this.cmbMonth.SelectedItem.ToString().Trim();
                        time  = year + "-" + month;
                    }
                }
                string sql_1   = String.Format("select count(*) from t_salary where eno='{0}' and CONVERT(varchar(20), EnterTime, 120) like '{1}%'", Eno, time);
                int    count_1 = (int)DAO.ExecuteScalar(sql_1);
                if (count_1 <= 0)
                {
                    dgvPersonalSalary.Columns.Clear();
                    MessageBox.Show("该时间没有数据!!");
                    return;
                }
                else
                {
                    sql = String.Format("select sum(LevelSalary) as 基本工资, SUM(OvertimeWork) as 加班工资, SUM(BenifitSum) as 补贴, SUM(AllowanceSum) as 津贴, SUM(Awd_PunSum) as 奖惩总额, SUM(AllSum) as 总工资 from t_salary where eno='{0}' and CONVERT(varchar(20), EnterTime, 120) like '{1}%'", Eno, time);
                    DataTable dt = DAO.GetTable(sql);
                    InitialDataGridView(dgvPersonalSalary, dt);
                }
            }
        }
示例#2
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            string[] salary = new string[6];
            string   time   = "";
            string   sql    = String.Format("select deptno from t_employee where eno='{0}'", Eno);

            deptno = int.Parse(DAO.ExecuteScalar(sql).ToString());
            if (level == 0)//按年
            {
                if (cmbYear.SelectedIndex == -1)
                {
                    dataGridView1.Columns.Clear();
                    pnlDepartment.Visible = false;
                    MessageBox.Show("请选择时间!");
                    return;
                }
                else
                {
                    time = cmbYear.SelectedItem.ToString();
                    string sql_0   = String.Format("select COUNT(*) from t_Salary a, t_Employee b where a.Eno=b.Eno and DeptNo=(select DeptNo from t_Employee where Eno='{0}') and CONVERT(varchar(20), EnterTime, 120) like '{1}%'", Eno, time);
                    int    count_0 = (int)DAO.ExecuteScalar(sql_0);
                    if (count_0 <= 0)
                    {
                        dataGridView1.Columns.Clear();
                        MessageBox.Show("该时间没有数据!");
                        return;
                    }
                    else
                    {
                        string    sql_1 = String.Format("select sum(LevelSalary) as 基本工资, SUM(OvertimeWork) as 加班工资, SUM(BenifitSum) as 补贴, SUM(AllowanceSum) as 津贴, SUM(Awd_PunSum) as 奖惩总额, SUM(AllSum) as 总工资 from t_Salary a, t_Employee b where a.Eno=b.Eno and CONVERT(varchar(20), EnterTime, 120) like '{0}%' and DeptNo=(select DeptNo from t_Employee where Eno='{1}')", time, Eno);
                        DataTable dt    = DAO.GetTable(sql_1);
                        DataRow   dr    = dt.Rows[0];
                        for (int i = 0; i < 6; i++)
                        {
                            salary[i] = dr[i].ToString();
                        }

                        txtBasicSal.Text = salary[0];
                        txtOverWork.Text = salary[1];
                        txtBenifit.Text  = salary[2];
                        txtAllwance.Text = salary[3];
                        txtAwd_Pun.Text  = salary[4];
                        txtAllSum.Text   = salary[5];

                        string    sql_2 = String.Format("select LevelSalary as 基本工资, OvertimeWork as 加班工资, BenifitSum as 补贴, AllowanceSum as 津贴, Awd_PunSum as 奖惩总额, AllSum as 总工资 from t_Salary a, t_Employee b where a.Eno=b.Eno and CONVERT(varchar(20), EnterTime, 120) like '{0}%' and DeptNo=(select DeptNo from t_Employee where Eno='{1}')", time, Eno);
                        DataTable dt_2  = DAO.GetTable(sql_2);
                        InitialDataGridView(dataGridView1, dt_2);
                        pnlDepartment.Visible       = true;
                        cmbDepartment.SelectedIndex = deptno - 1;
                    }
                }
            }
            else//按月
            {
                if (cmbYear.SelectedIndex == -1 && cmbMonth.SelectedIndex == -1)
                {
                    dataGridView1.Columns.Clear();
                    pnlDepartment.Visible = false;
                    MessageBox.Show("请选择时间!");
                    return;
                }
                else
                {
                    time = cmbYear.SelectedItem.ToString().Trim() + "-" + cmbMonth.SelectedItem.ToString().Trim();
                    string sql_0   = String.Format("select COUNT(*) from t_Salary a, t_Employee b where a.Eno=b.Eno and DeptNo=(select DeptNo from t_Employee where Eno='{0}') and CONVERT(varchar(20), EnterTime, 120) like '{1}%'", Eno, time);
                    int    count_0 = (int)DAO.ExecuteScalar(sql_0);
                    if (count_0 <= 0)
                    {
                        dataGridView1.Columns.Clear();
                        MessageBox.Show("该时间没有数据!");
                        return;
                    }
                    else
                    {
                        string    sql_1 = String.Format("select sum(LevelSalary) as 基本工资, SUM(OvertimeWork) as 加班工资, SUM(BenifitSum) as 补贴, SUM(AllowanceSum) as 津贴, SUM(Awd_PunSum) as 奖惩总额, SUM(AllSum) as 总工资 from t_Salary a, t_Employee b where a.Eno=b.Eno and CONVERT(varchar(20), EnterTime, 120) like '{0}%' and DeptNo=(select DeptNo from t_Employee where Eno='{1}')", time, Eno);
                        DataTable dt    = DAO.GetTable(sql_1);
                        DataRow   dr    = dt.Rows[0];
                        for (int i = 0; i < 6; i++)
                        {
                            salary[i] = dr[i].ToString();
                        }

                        txtBasicSal.Text = salary[0];
                        txtOverWork.Text = salary[1];
                        txtBenifit.Text  = salary[2];
                        txtAllwance.Text = salary[3];
                        txtAwd_Pun.Text  = salary[4];
                        txtAllSum.Text   = salary[5];

                        string    sql_2 = String.Format("select LevelSalary as 基本工资, OvertimeWork as 加班工资, BenifitSum as 补贴, AllowanceSum as 津贴, Awd_PunSum as 奖惩总额, AllSum as 总工资 from t_Salary a, t_Employee b where a.Eno=b.Eno and CONVERT(varchar(20), EnterTime, 120) like '{0}%' and DeptNo=(select DeptNo from t_Employee where Eno='{1}')", time, Eno);
                        DataTable dt_2  = DAO.GetTable(sql_2);
                        InitialDataGridView(dataGridView1, dt_2);
                        pnlDepartment.Visible       = true;
                        cmbDepartment.SelectedIndex = deptno - 1;
                    }
                }
            }
        }
        private void LoadData(string time, GroupBox gpb)
        {
            int deptno = int.Parse(gpb.Tag.ToString());

            string[]  salary = new string[6];
            string    sql_1  = String.Format("select sum(LevelSalary) as 基本工资, SUM(OvertimeWork) as 加班工资, SUM(BenifitSum) as 补贴, SUM(AllowanceSum) as 津贴, SUM(Awd_PunSum) as 奖惩总额, SUM(AllSum) as 总工资 from t_Salary a, t_Employee b where a.Eno=b.Eno and CONVERT(varchar(20), EnterTime, 120) like '{0}%' and DeptNo='{1}'", time, deptno);
            DataTable dt_1   = DAO.GetTable(sql_1);
            DataRow   dr_1   = dt_1.Rows[0];

            for (int i = 0; i < 6; i++)
            {
                salary[i] = dr_1[i].ToString();
            }
            if (deptno == 1)
            {
                this.txtRS_BasicSal.Text = salary[0];
                txtRS_OverWork.Text      = salary[1];
                txtRS_Benifit.Text       = salary[2];
                txtRS_Allwance.Text      = salary[3];
                txtRS_Awd_Pun.Text       = salary[4];
                txtRS_AllSum.Text        = salary[5];
            }
            else if (deptno == 2)
            {
                txtSC_BasicSal.Text = salary[0];
                txtSC_OverWork.Text = salary[1];
                txtSC_Benifit.Text  = salary[2];
                txtSC_Allwance.Text = salary[3];
                txtSC_Awd_Pun.Text  = salary[4];
                txtSC_AllSum.Text   = salary[5];
            }
            else
            {
                txtCW_BasicSal.Text = salary[0];
                txtCW_OverWork.Text = salary[1];
                txtCW_BasicSal.Text = salary[2];
                txtCW_Allwance.Text = salary[3];
                txtCW_Awd_Pun.Text  = salary[4];
                txtCW_AllSum.Text   = salary[5];
            }


            string    sql_2 = String.Format("select a.Eno as 编号, b.EName as 姓名, LevelSalary as 基本工资, OvertimeWork as 加班工资, BenifitSum as 补贴, AllowanceSum as 津贴, Awd_PunSum as 奖惩总额, AllSum as 总工资 from t_Salary a, t_Employee b where a.Eno=b.Eno and CONVERT(varchar(20), EnterTime, 120) like '{0}%' and DeptNo='{1}'", time, deptno);
            DataTable dt_2  = DAO.GetTable(sql_2);

            foreach (Control c in gpb.Controls)
            {
                if (c is DataGridView)
                {
                    DataGridView dgv = (DataGridView)c;
                    InitialDataGridView(dgv, dt_2);
                }
            }

            foreach (Control c in gpb.Controls)
            {
                if (c is TextBox)
                {
                    if (c.Text == "")
                    {
                        c.Text = "0";
                    }
                }
            }
        }