예제 #1
0
        private void btnCheckin_Click(object sender, EventArgs e)//签到
        {
            DateTime datetime = DateTime.Now;
            string   time     = datetime.ToShortDateString();
            string   sql_0    = String.Format("select COUNT(*) from t_CheckRecord where Eno='{0}' and CONVERT(varchar(20), OnWorkTime, 120) like '{1}%'", Eno, time);
            int      flag_0   = (int)DAO.ExecuteScalar(sql_0);

            if (flag_0 == 0)
            {
                string sql_1  = String.Format("insert into t_CheckRecord values('{0}', '{1}', '{2}', '{3}')", Eno, this.lblTime.Text, null, null);//签到时还没有下班时间和加班时长
                int    flag_1 = DAO.ExecuteNonQuery(sql_1);
                if (flag_1 != 0)
                {
                    MessageBox.Show("签到成功!");
                    return;
                }
                else
                {
                    MessageBox.Show("签到失败,请重试!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("你今日已经签到,请认真上班!");
                return;
            }
        }
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (txtEno.Text == "")
            {
                MessageBox.Show("请输入编号!");
                return;
            }
            else
            {
                eno = int.Parse(txtEno.Text);
                string sql_0   = String.Format("select count(*) from t_salary where eno ='{0}'", eno);
                int    count_0 = (int)DAO.ExecuteScalar(sql_0);
                if (count_0 == 0)
                {
                    MessageBox.Show("没有该员工工资信息!");

                    return;
                }
                else
                {
                    string    sql_1 = String.Format("select a.Eno as 员工编号, b.EName as 姓名 ,LevelSalary as 基本工资, OvertimeWork as 加班工资, BenifitSum as 津贴总额, AllowanceSum as 补贴总额, Awd_PunSum as 奖惩总额, AllSum as 工资总额, EnterTime as 时间 from t_Salary a, t_Employee b where a.Eno=b.Eno and  a.Eno='{0}'", eno);
                    DataTable dt    = DAO.GetTable(sql_1);
                    InitialDatagridview(dgvPersonalSalary, dt);
                }
            }
        }
 private void FrmBrowseSalary_Load(object sender, EventArgs e)
 {
     if (authority == 0)
     {
         btnBrowse.Visible             = true;
         toolStripStatusLabel1.Visible = false;
     }
     else
     {
         btnBrowse.Visible = false;
         txtEno.Text       = eno.ToString();
         string datetime = DateTime.Now.ToShortDateString().Substring(0, 7);
         string sql_0    = String.Format("select count(*) from t_salary where eno ='{0}' and CONVERT(varchar(20), entertime, 120) like '{1}%'", eno, datetime);
         int    count_0  = (int)DAO.ExecuteScalar(sql_0);
         if (count_0 == 0)
         {
             MessageBox.Show("没有本月工资记录!");
             return;
         }
         else
         {
             string    sql_1 = String.Format("select * from t_salary where eno ='{0}' and CONVERT(varchar(20), entertime, 120) like '{1}%'", eno, datetime);
             DataTable dt    = DAO.GetTable(sql_1);
             InitialDatagridview(dgvPersonalSalary, dt);
         }
     }
 }
        private void btnLoadByNo_Click(object sender, EventArgs e)
        {
            if (txtNo.Text == "")
            {
                MessageBox.Show("请输入编号!");
                return;
            }
            else
            {
                Eno = int.Parse(txtNo.Text);
                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)
                {
                    MessageBox.Show("请输入正确的编号!");
                    return;
                }
                else
                {
                    string    sql = String.Format("select EName, DeptNo, LevelNo from t_Employee where Eno='{0}'", Eno);
                    DataTable dt  = DAO.GetTable(sql);
                    txtName.Text              = dt.Rows[0][0].ToString();
                    cmbDept.SelectedIndex     = int.Parse(dt.Rows[0][1].ToString()) - 1;
                    cmbPosition.SelectedIndex = int.Parse(dt.Rows[0][2].ToString()) - 1;

                    btnLoadByName.Visible    = false;
                    this.cmbDept.Enabled     = true;
                    this.cmbPosition.Enabled = true;
                }
            }
        }
예제 #5
0
 private void btnBrowseAwd_Click(object sender, EventArgs e)
 {
     if (txtNo.Text == null || txtNo.Text == "")
     {
         MessageBox.Show("请输入编号!!");
         return;
     }
     else
     {
         ENo = int.Parse(txtNo.Text);
         string datetime = DateTime.Now.ToShortDateString();
         datetime = datetime.Substring(0, 6);
         string sql   = String.Format("select COUNT(*) from t_Pun_Awar_Record where Eno='{0}' and CONVERT(varchar(20), PWTime, 120) like '{1}%'", ENo, datetime);
         int    count = (int)DAO.ExecuteScalar(sql);
         if (count > 0)
         {
             FrmBrowseAwd_PunLog frm = new FrmBrowseAwd_PunLog(ENo);
             frm.ShowDialog();
         }
         else
         {
             MessageBox.Show("所选职工本月没有奖惩记录");
         }
     }
 }
예제 #6
0
        int flag     = 0; //判断修改或新增
        public FrmAwd_PunStandard()
        {
            InitializeComponent();
            string sql_0 = String.Format("select COUNT(*) from t_Pun_Awar_Standard");

            allcount = (int)DAO.ExecuteScalar(sql_0);
        }
예제 #7
0
        private void FrmAttendenceRecord_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            string sql_0 = String.Format("select EName from t_Employee where Eno = '{0}'", Eno);

            this.sslblName.Text = DAO.ExecuteScalar(sql_0).ToString();
        }
예제 #8
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int count    = 0;
            int allcount = 0;

            if (txtNo.Text == "" || txtNo.Text == "0")
            {
                MessageBox.Show("请输入编号!");
                return;
            }
            else
            {
                Eno = int.Parse(txtNo.Text.Trim());
                string time     = DateTime.Now.ToString();
                string datetime = DateTime.Now.ToShortDateString();
                foreach (CheckBox cb in pnlAwd_Pun.Controls)
                {
                    if (cb.Checked == true)
                    {
                        int    pw_no  = int.Parse(cb.Tag.ToString().Trim());
                        string sql_0  = String.Format("select count(*)from t_Pun_Awar_Record where Eno='{0}' and CONVERT(varchar(20), PWTime, 120) like '{1}%' and PWNo='{2}'", Eno, datetime, pw_no);
                        int    flag_0 = (int)DAO.ExecuteScalar(sql_0);
                        if (flag_0 == 0)
                        {
                            string sql  = String.Format("insert into t_Pun_Awar_Record values('{0}','{1}','{2}')", Eno, time, pw_no);
                            int    flag = DAO.ExecuteNonQuery(sql);
                            if (flag != 0)
                            {
                                count++;
                            }
                        }
                        else
                        {
                            MessageBox.Show("对不起,已有" + cb.Text.Trim() + "此奖惩记录!");
                        }
                        allcount++;
                    }
                }
            }

            if (count == allcount)
            {
                MessageBox.Show("插入成功!");
                return;
            }
            else if (count < allcount && count > 0)
            {
                MessageBox.Show("部分插入成功!");
                return;
            }
            else
            {
                MessageBox.Show("插入失败!");
                return;
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            string categorycontent = null;
            string position        = null;

            position = this.comboBox1.Text.Trim();

            foreach (CheckBox cb in pnlCheckBox.Controls)
            {
                if (cb.Checked == true)
                {
                    categorycontent += cb.Tag.ToString() + "+";
                }
            }
            categorycontent = categorycontent.Remove(categorycontent.Length - 1, 1);
            //检查是否有相同职位的工资标准存在
            string sql_0   = String.Format("select count(*) from t_SalaryCategory where position='{0}'", position);
            int    count_0 = (int)DAO.ExecuteScalar(sql_0);

            if (count_0 == 1)
            {
                DialogResult dr = MessageBox.Show("已有数据,是否修改?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    string sql_2 = String.Format("update t_SalaryCategory set CategoryContent='{0}' where position='{1}'", categorycontent.Trim(), position);
                    int    flag  = DAO.ExecuteNonQuery(sql_2);

                    if (flag == 1)
                    {
                        MessageBox.Show("修改成功!");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("修改失败!");
                        return;
                    }
                }
            }
            else//没有当下用户选择的职位的工资标准
            {
                string sql_2 = String.Format("insert into t_SalaryCategory values('{0}', '{1}')", categorycontent.Trim(), position);
                int    flag  = DAO.ExecuteNonQuery(sql_2);
                if (flag == -1)
                {
                    MessageBox.Show("插入成功!");
                }
                else
                {
                    MessageBox.Show("插入失败!");
                }
                return;
            }
        }
예제 #10
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            string time  = "";
            string sql   = "";
            string year  = "";
            string month = "";

            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);
            }
        }
예제 #11
0
        private void btnCheckout_Click(object sender, EventArgs e)
        {
            string TodayTime     = this.lblTime.Text.Trim();
            string TodayDateTime = TodayTime.Remove(10, TodayTime.Length - 10);

            string sql_2   = String.Format("select COUNT(*) from t_CheckRecord where CONVERT(varchar(20), OnWorkTime, 120) like '{0}%' and eno ='{1}'", TodayDateTime, Eno);
            int    count_2 = (int)DAO.ExecuteScalar(sql_2);

            if (count_2 == 1)
            {
                string   sql_3       = String.Format("select OnWorkTime from t_CheckRecord where CONVERT(varchar(20), OnWorkTime, 120) like '{0}%' and eno ='{1}'", TodayDateTime, Eno);
                DateTime CheckinTime = (DateTime)DAO.ExecuteScalar(sql_3);
                DateTime offWorkTime = DateTime.Parse(TodayTime);
                TimeSpan ts          = offWorkTime.Subtract(CheckinTime);

                string time   = TodayTime.ToString();
                string sql_1  = String.Format("select count(*) from t_CheckRecord where CONVERT(varchar(20), OffWorkTime, 120) like '{0}%' and eno ='{1}'", time, Eno);
                int    flag_1 = (int)DAO.ExecuteScalar(sql_1);
                if (flag_1 == 0)
                {
                    int    hours  = int.Parse(ts.Hours.ToString());
                    string sql_4  = String.Format("update t_CheckRecord set OffWorkTime = '{0}', worktime='{1}' where eno='{2}' and CONVERT(varchar(20), OnWorkTime, 120) like '{3}%'", TodayTime, hours, Eno, TodayDateTime);
                    int    flag_4 = DAO.ExecuteNonQuery(sql_4);
                    if (flag_4 != 0)
                    {
                        MessageBox.Show("签离成功!");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("签离失败,请重试!");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("你有多个签离记录,请与人事部联系!");
                    return;
                }
            }
            else if (count_2 == 0)
            {
                MessageBox.Show("对不起,今天没有你的签到记录!请与人事部联系");
                return;
            }
            else if (count_2 > 1)
            {
                MessageBox.Show("今天有多个签到记录,请与人事部联系");
                return;
            }
        }
예제 #12
0
        public void ChangeAuthority()
        {
            if (txtEno.Text != "")
            {
                string sql = String.Format("select Authority from t_Employee where Eno='{0}'", txtEno.Text.Trim());
                Authority = (int)DAO.ExecuteScalar(sql);

                this.comboBox1.Text = comboBox1.Items[Authority].ToString();
                if (Authority > 0)
                {
                    this.comboBox1.Enabled = false;
                }
            }
        }
예제 #13
0
        private void btnSumUp_Click(object sender, EventArgs e)
        {
            if (txtNo.Text == null || txtNo.Text == "")
            {
                MessageBox.Show("请输入编号!!");
                return;
            }
            else
            {
                ENo = int.Parse(txtNo.Text.Trim());
                EverySum();

                string sql_0  = String.Format("select LevelSalary from t_Employee, t_SalaryRank where Eno='{0}' and t_Employee.LevelNo=t_SalaryRank.LevelNo", ENo);
                string salary = DAO.ExecuteScalar(sql_0).ToString();
                salary      = salary.Substring(0, salary.IndexOf('.'));
                basicsalary = float.Parse(salary);

                string datetime = DateTime.Now.ToShortDateString();
                datetime = datetime.Substring(0, 7);
                //按月份查询
                string sql_1 = String.Format("select AVG(WorkTime) from t_CheckRecord where Eno='{0}' and CONVERT(varchar(20), OffWorkTime, 120) like '{1}%'", ENo, datetime);
                if (DAO.ExecuteScalar(sql_1).ToString() == "")
                {
                    overtime_sum = 0;
                }
                else
                {
                    float avgworktime = float.Parse(DAO.ExecuteScalar(sql_1).ToString());
                    if (avgworktime - 9 >= 0)
                    {
                        overtime_sum = (avgworktime - 9) * 80;//加上中午一小时休息时间 =.=
                    }
                    else
                    {
                        overtime_sum = 0;
                    }
                }

                if (overtime_sum <= 0)
                {
                    overtime_sum = 0;
                }
                float AllSum = basicsalary + allow_sum + benifit_sum + awd_sum + pun_sum + overtime_sum;

                this.txtAllSum.Text = AllSum.ToString();
            }
        }
예제 #14
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int    count = 0;
            string sql   = "select count(*) from t_salary";

            count = (int)DAO.ExecuteScalar(sql);
            if (count <= 0)
            {
                MessageBox.Show("无工资记录!");
                return;
            }
            else
            {
                FrmCheckAttendenceLog frm = new FrmCheckAttendenceLog(Eno, 2);
                frm.ShowDialog();
            }
        }
예제 #15
0
 /// <summary>
 /// 初始化表面数据
 /// </summary>
 /// <param name="eno"></param>
 /// <param name="cno"></param>
 private void InitializeData(int eno, int cno)
 {
     if (eno == 0)//没有编号
     {
         string sql_0   = String.Format("select count(*) from t_ContractDetail where ContractNo='{0}'", cno);
         int    count_0 = (int)DAO.ExecuteScalar(sql_0);
         if (count_0 > 0)
         {
             MessageBox.Show("数据不正确!");
             return;
         }
         else
         {
             string    sql_1    = String.Format("select * from t_ContractDetail where ContractNo='{0}'", cno);
             DataTable dt       = DAO.GetTable(sql_1);
             string[]  contract = new string[10];
             for (int i = 0; i < 10; i++)
             {
                 contract[i] = dt.Rows[0][i].ToString();
             }
             LoadData(contract);
         }
     }
     else
     {
         string sql_0   = String.Format("select count(*) from t_ContractDetail where Eno ='{0}' and ContractNo='{1}'", eno, cno);
         int    count_0 = (int)DAO.ExecuteScalar(sql_0);
         if (count_0 > 0)
         {
             MessageBox.Show("数据不正确!");
             return;
         }
         else
         {
             string    sql_1    = String.Format("select * from t_ContractDetail where ContractNo='{0}' and Eno='{1}'", cno, eno);
             DataTable dt       = DAO.GetTable(sql_1);
             string[]  contract = new string[10];
             for (int i = 0; i < 10; i++)
             {
                 contract[i] = dt.Rows[0][i].ToString();
             }
             LoadData(contract);
         }
     }
 }
        private void cmbDepartment_SelectedIndexChanged(object sender, EventArgs e)
        {
            datetime = DateTime.Now.ToShortDateString();
            datetime = datetime.Substring(0, 7);
            dept     = cmbDepartment.SelectedIndex + 1;
            DataTable dt      = new DataTable();
            string    sql_0   = String.Format("select COUNT(*) from t_Salary where CONVERT(varchar(20), EnterTime, 120) like '{0}%' and Eno in(select Eno from t_Employee where DeptNo='{1}')", datetime, dept);
            int       count_0 = (int)DAO.ExecuteScalar(sql_0);

            if (count_0 > 0)
            {
                string sql = String.Format("select AllSum as 个人总工资, eno as 员工编号 from t_Salary where CONVERT(varchar(20), EnterTime, 120) like '{0}%' and Eno in(select Eno from t_Employee where DeptNo='{1}')", datetime, dept);
                dt = DAO.GetTable(sql);
                InitialDatagridview(dgvDepartmentSalary, dt);
                string sql_2 = String.Format("select SUM(AllSum) from t_Salary where CONVERT(varchar(20), EnterTime, 120) like '{0}%' and Eno in (select Eno from t_Employee where DeptNo='{1}')", datetime, dept);
                this.txtSum.Text = DAO.ExecuteScalar(sql_2).ToString();
                txtSum.ReadOnly  = true;
            }
        }
예제 #17
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            string datetime = this.lblTime.Text.Trim();

            datetime = datetime.Remove(8, datetime.Length - 8);
            string sql_0   = String.Format("select count(*) from t_checkrecord where eno='{0}'", Eno);
            int    count_0 = (int)DAO.ExecuteScalar(sql_0);

            if (count_0 <= 0)
            {
                MessageBox.Show("没有出勤记录!");
                return;
            }
            else
            {
                FrmAttendenceBrowse frm_1 = new FrmAttendenceBrowse(datetime, this.sslblName.Text.Trim(), Eno);
                frm_1.ShowDialog();
            }
        }
        private void btnLoadByName_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("请输入姓名!");
                return;
            }
            else
            {
                int count = 0;
                Ename = txtName.Text.Trim();
                string sql_0 = String.Format("select count(*) from t_employee where ename='{0}'", txtName.Text.Trim());
                count = (int)DAO.ExecuteScalar(sql_0);

                if (count > 0)
                {
                    if (count > 1)
                    {
                        MessageBox.Show("有多个数据,请输入编号!");
                        btnLoadByName.Visible = false;
                        return;
                    }
                    else if (count == 1)
                    {
                        string    sql_1 = String.Format("select eno, DeptNo, LevelNo from t_Employee where EName='{0}'", Ename);
                        DataTable dt    = DAO.GetTable(sql_1);
                        txtNo.Text                = dt.Rows[0][0].ToString();
                        cmbDept.SelectedIndex     = int.Parse(dt.Rows[0][1].ToString()) - 1;
                        cmbPosition.SelectedIndex = int.Parse(dt.Rows[0][2].ToString()) - 1;

                        btnLoadByNo.Visible      = false;
                        this.cmbDept.Enabled     = true;
                        this.cmbPosition.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("数据有误!!");
                    return;
                }
            }
        }
예제 #19
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Eno      = int.Parse(this.txtEno.Text.ToString().Trim());
            Password = int.Parse(this.txtPwd.Text.ToString().Trim());
            string sql = String.Format("select count(*) from dbo.t_Employee where ENo='{0}' and password='******'", Eno, Password);

            Authority = comboBox1.SelectedIndex;
            int flag = (int)DAO.ExecuteScalar(sql);

            if (flag == 1)
            {
                this.DialogResult = DialogResult.OK;
                user.Eno          = Eno;
                user.Authority    = Authority;
            }
            else
            {
                MessageBox.Show("用户信息错误!!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.DialogResult = DialogResult.Cancel;
            }
        }
예제 #20
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtEno.Text == "" || cmbOn_OffType.SelectedIndex < 0 || txtReason.Text == "")
     {
         MessageBox.Show("请输入完全!");
         return;
     }
     else
     {
         eno      = int.Parse(txtEno.Text);
         type     = cmbOn_OffType.SelectedItem.ToString();
         reason   = txtReason.Text;
         datetime = DateTime.Now.ToString();
         string sql   = String.Format("select count(*) from t_employee where eno='{0}'", eno);
         int    count = (int)DAO.ExecuteScalar(sql);
         if (count <= 0)
         {
             MessageBox.Show("没有此员工信息");
             return;
         }
         else
         {
             string sql_1  = String.Format("insert into [t_On/OffDutyRecord] values('{0}','{1}','{2}','{3}')", eno, type, reason, datetime);
             int    flag_1 = DAO.ExecuteNonQuery(sql_1);
             if (flag_1 != 0)
             {
                 MessageBox.Show("添加成功!");
                 return;
             }
             else
             {
                 MessageBox.Show("添加失败!");
                 return;
             }
         }
     }
 }
예제 #21
0
 private void btnBrowseAttendence_Click(object sender, EventArgs e)
 {
     if (txtNo.Text == null || txtNo.Text == "")
     {
         MessageBox.Show("请重新选择员工!");
         return;
     }
     else
     {
         ENo = int.Parse(txtNo.Text.Trim());
         string sql   = String.Format("select count(*) from t_CheckRecord where Eno='{0}' and CONVERT(varchar(20), OffWorkTime, 120) like '{1}%'", ENo, DateTime.Now.ToShortDateString().Substring(0, 7));
         int    count = (int)DAO.ExecuteScalar(sql);
         if (count <= 0)
         {
             MessageBox.Show("本月没有职工考勤记录!");
             return;
         }
         else
         {
             FrmCheckAttendenceLog frm = new FrmCheckAttendenceLog(ENo, 0);
             frm.ShowDialog();
         }
     }
 }
예제 #22
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;
                    }
                }
            }
        }
예제 #23
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (CheckData() == false)
     {
         MessageBox.Show("请填写完整!");
         return;
     }
     else
     {
         string datetime = DateTime.Now.ToString();
         if (rdoFemale.Checked == true)
         {
             gender = 0;
         }
         else
         {
             gender = 1;
         }
         string sql_0   = String.Format("select count(*) from t_ContractDetail where eno ='{0}'", int.Parse(txtEno.Text));
         int    count_0 = (int)DAO.ExecuteScalar(sql_0);
         string sql_5   = String.Format("select count(*) from t_employee where eno='{0}'", int.Parse(txtEno.Text));
         int    count_5 = (int)DAO.ExecuteNonQuery(sql_5);
         if (frmtype == 0)//新增保存
         {
             if (count_0 > 0 || count_5 > 0)
             {
                 MessageBox.Show("已有此编号的员工,请重试!!");
                 return;
             }
             else
             {
                 eno           = int.Parse(txtEno.Text);
                 contractypeno = cmbContractType.SelectedIndex + 1;
                 deptno        = cmbDepartment.SelectedIndex + 1;
                 jobposition   = cmbJobPosition.SelectedItem.ToString();
                 ename         = txtName.Text;
                 eid           = txtID.Text;
                 etel          = txtPhoneNumber.Text;
                 int    levelno = cmbJobPosition.SelectedIndex + 1;
                 string sql_1   = String.Format("insert into dbo.t_ContractDetail values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", contractypeno, eno, deptno, jobposition, ename, gender, eid, etel, datetime);
                 int    flag_1  = DAO.ExecuteNonQuery(sql_1);
                 string sql_2   = String.Format("insert into t_Employee (Eno, DeptNo, LevelNo, EName, EGender, EId, ETel) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", eno, deptno, levelno, ename, gender, eid, etel);
                 int    flag_2  = DAO.ExecuteNonQuery(sql_2);
                 if (flag_1 != 0 && flag_2 != 0)
                 {
                     MessageBox.Show("新增成功");
                     ClearData();
                     return;
                 }
                 else
                 {
                     MessageBox.Show("新增失败");
                     ClearData();
                     return;
                 }
             }
         }
         else//修改保存
         {
             if (count_0 <= 0)
             {
                 MessageBox.Show("没有此员工信息!");
                 return;
             }
             else
             {
                 eno           = int.Parse(txtEno.Text);
                 contractypeno = cmbContractType.SelectedIndex + 1;
                 deptno        = cmbDepartment.SelectedIndex + 1;
                 jobposition   = cmbJobPosition.SelectedItem.ToString();
                 ename         = txtName.Text;
                 eid           = txtID.Text;
                 etel          = txtPhoneNumber.Text;
                 int    levelno = cmbJobPosition.SelectedIndex + 1;
                 string sql     = String.Format("update t_ContractDetail set ContractTypeNo='{0}', Eno='{1}',deptno='{2}',jobposition='{3}', ename='{4}',egender='{5}', eid='{6}',etel='{7}',effecttime='{8}'where contractno='{9}'", contractypeno, eno, deptno, jobposition, ename, gender, eid, etel, datetime, int.Parse(txtContractNo.Text.ToString()));
                 int    flag    = DAO.ExecuteNonQuery(sql);
                 string sql_3   = String.Format("update t_Employee set DeptNo='{0}', LevelNo='{1}',EName='{2}',EGender='{3}',EId='{4}',ETel='{5}' where Eno='{6}'", deptno, levelno, ename, gender, eid, etel, eno);
                 int    flag_3  = DAO.ExecuteNonQuery(sql_3);
                 if (flag != 0 && flag_3 != 0)
                 {
                     MessageBox.Show("修改成功");
                     ClearData();
                     return;
                 }
                 else
                 {
                     MessageBox.Show("修改失败");
                     ClearData();
                     return;
                 }
             }
         }
     }
 }
        private void btnOK_Click(object sender, EventArgs e)
        {
            int deptno           = 0;
            int levelno          = 0;
            int salarycategoryno = 0;
            int gender           = 0;

            //检查必填项
            if (this.txtNo.Text == "")
            {
                MessageBox.Show("请重新输入!");
                return;
            }
            else if (cbDepartment.SelectedIndex < 0 || cbPosition.SelectedIndex < 0 || cmbAuthority.SelectedIndex < 0)
            {
                MessageBox.Show("请重新输入!");
                return;
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("请重新输入!");
                return;
            }

            int p_eno = int.Parse(txtNo.Text.ToString());

            string sql_1 = String.Format("select DeptNo from t_Department where DeptName='{0}'", this.cbDepartment.Text.Trim());

            deptno = int.Parse(DAO.ExecuteScalar(sql_1).ToString());

            string sql_2 = String.Format("select LevelNo from t_SalaryRank where LevelName='{0}'", this.cbPosition.Text.Trim());

            levelno = int.Parse(DAO.ExecuteScalar(sql_2).ToString());

            string sql_5 = String.Format("select SalaryCategoryNo from t_SalaryCategory where Position='{0}'", this.cbPosition.Text);

            salarycategoryno = int.Parse(DAO.ExecuteScalar(sql_5).ToString());

            if (this.rdobtnFemale.Checked == true)
            {
                gender = 0;
            }
            else
            {
                gender = 1;
            }

            string sql   = String.Format("select COUNT(*) from t_Employee where Eno='{0}'", p_eno);
            int    count = (int)DAO.ExecuteScalar(sql);

            Eno = int.Parse(txtNo.Text);
            string name        = txtName.Text.Trim();
            string eid         = txtSocialID.Text.Trim();
            string nationality = txtNationality.Text;
            string politic     = txtPolitic.Text;
            string etel        = txtMobilePhone.Text;
            string email       = txtEmailAddress.Text;
            string address     = txtAddress.Text;
            string marriage    = txtMarriageStatus.Text;
            int    worktime    = 0;
            string workphone   = txtWorkPhoneNumber.Text;
            string password    = txtPassword.Text;
            int    authority   = 0;

            authority = this.cmbAuthority.SelectedIndex;

            if (count == 0)  //新增
            {
                string sql_4  = String.Format("insert into t_Employee values('{0}', '{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','(16)')", Eno, deptno, levelno, name, gender, eid, nationality, politic, etel, email, address, marriage, worktime, workphone, salarycategoryno, password, authority);
                int    flag_4 = DAO.ExecuteNonQuery(sql_4);
                if (flag_4 != 0)
                {
                    MessageBox.Show("添加成功!");
                    return;
                }
                else
                {
                    MessageBox.Show("添加失败!");
                    return;
                }
            }
            else  //修改
            {
                string sql_3 = String.Format("update t_Employee set DeptNo='{0}', LevelNo='{1}', EName='{2}', EGender='{3}', EId='{4}', ENationality='{5}', EPolitical='{6}', ETel='{7}', EEmail='{8}', EAddress='{9}', EMarriage='{10}', Eph='{11}', EWorktime='{12}', [Password]='{13}', Authority='{14}',  SalaryCategoryNo='{15}' where Eno='{16}'", deptno, levelno, txtName.Text, gender, txtSocialID.Text, txtNationality.Text, txtPolitic.Text, txtMobilePhone.Text, txtEmailAddress.Text, txtAddress.Text, txtMarriageStatus.Text, txtWorkPhoneNumber.Text, txtWorkTime.Text, txtPassword.Text, authority, salarycategoryno, Eno);
                int    flag  = DAO.ExecuteNonQuery(sql_3);
                if (flag != 0)
                {
                    MessageBox.Show("修改成功!");
                    return;
                }
                else
                {
                    MessageBox.Show("修改失败!");
                    return;
                }
            }
        }
예제 #25
0
        private void txtNo_Leave(object sender, EventArgs e)
        {
            if (Type == 0)
            {
                if (this.txtNo.Text == "")
                {
                    MessageBox.Show("请输入编号!");
                    return;
                }
                else
                {
                    ENo = int.Parse(this.txtNo.Text.Trim());
                    string sql_0   = String.Format("select count(*) from t_Employee where Eno='{0}'", this.txtNo.Text.Trim());
                    int    count_0 = (int)DAO.ExecuteScalar(sql_0);
                    if (count_0 == 0)
                    {
                        MessageBox.Show("没有对应员工信息,请重新输入编号!");
                        return;
                    }
                    else
                    {
                        string sql_1          = String.Format("select CategoryContent from t_Employee, t_SalaryCategory where t_Employee.SalaryCategoryNo = t_SalaryCategory.SalaryCategoryNo and Eno='{0}'", ENo);
                        string salarycategory = DAO.ExecuteScalar(sql_1).ToString();
                        int    index          = 0;
                        index = salarycategory.IndexOf('2');
                        if (index > 0 && index < salarycategory.Length)
                        {
                            gpbAwllance.Enabled = true;
                        }
                        else
                        {
                            gpbAwllance.Enabled = false;
                        }
                        index = 0;
                        index = salarycategory.IndexOf('3');
                        if (index > 0 && index < salarycategory.Length)
                        {
                            gpbBenifit.Enabled = true;
                        }
                        else
                        {
                            gpbBenifit.Enabled = false;
                        }
                        index = 0;
                        index = salarycategory.IndexOf('5');
                        if (index > 0 && index < salarycategory.Length)
                        {
                            gpbAwd.Enabled = true;
                            gpbPun.Enabled = true;
                        }
                        else
                        {
                            gpbAwllance.Enabled = false;
                            gpbPun.Enabled      = false;
                        }
                    }

                    btnBrowseAwd.Enabled        = true;
                    btnBrowseAttendence.Enabled = true;
                    btnSumUp.Enabled            = true;
                }
            }
        }
예제 #26
0
        private void btnSubmitt_Click(object sender, EventArgs e)
        {
            ENo = int.Parse(this.txtNo.Text.Trim());
            DateTime dt = DateTime.Now;

            if (this.txtNo.Text == "")
            {
                MessageBox.Show("请输入编号!");
                return;
            }
            else
            {
                string sql_1   = String.Format("select COUNT(*) from t_Salary where Eno='{0}' and CONVERT(varchar(20), EnterTime, 120) like '{1}%'", ENo, dt.ToString().Substring(0, 7));
                int    count_1 = (int)DAO.ExecuteScalar(sql_1);
                allsum = int.Parse(txtAllSum.Text.ToString());
                if (Type == 0)//新增
                {
                    if (count_1 > 0)
                    {
                        MessageBox.Show("已有工资记录!");
                        return;
                    }
                    else
                    {
                        string sql  = String.Format("insert into t_Salary values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", txtNo.Text.Trim(), basicsalary, overtime_sum, benifit_sum, allow_sum, awd_sum + pun_sum, allsum, dt.ToString());
                        int    flag = DAO.ExecuteNonQuery(sql);
                        if (flag != 0)
                        {
                            MessageBox.Show("插入成功!");
                            return;
                        }
                        else
                        {
                            MessageBox.Show("插入失败!");
                            return;
                        }
                    }
                }
                else//修改
                {
                    if (count_1 == 0)
                    {
                        MessageBox.Show("此员工没有可供更改的工资条!");
                        return;
                    }
                    else
                    {
                        string sql  = String.Format("update t_Salary set levelsalary='{0}',overtimework='{1}',benifitsum='{2}',allowancesum='{3}',awd_punsum'{4}' , allsum='{5}' where eno='{6}' and CONVERT(varchar(20), EnterTime, 120) like {7}%", basicsalary, overtime_sum, benifit_sum, allow_sum, awd_sum + pun_sum, allsum, txtNo.Text.Trim(), dt.ToString().Substring(0, 7));
                        int    flag = DAO.ExecuteNonQuery(sql);
                        if (flag != 0)
                        {
                            MessageBox.Show("更新成功!");
                            return;
                        }
                        else
                        {
                            MessageBox.Show("更新失败!");
                            return;
                        }
                    }
                }
            }
        }