コード例 #1
0
        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";
                    }
                }
            }
        }
コード例 #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;
                    }
                }
            }
        }
コード例 #3
0
        private void unesi_Click(object sender, EventArgs e)
        {
            try
            {
                DAO dao = new DAO("etf.ba", "ooadtim6", "ooadtim6", "ooadtim6");
                // slika = new Bitmap(defaultpic);
                if (tabControl1.SelectedIndex == 0)
                {
                    if (ime.Text.Length < 1 || email.Text.Length < 1 || adresa.Text.Length < 1 || prezime.Text.Length < 1 || jmbg.Text.Length < 1 || telefon.Text.Length < 1)
                    {
                        toolStripStatusLabel1.Text = "Popunite sva polja";
                    }

                    else if ((IspravnaLicna(licna.Text)) && ime.Text.Length < 45 && email.Text.Length < 50 && adresa.Text.Length < 45 && provjeriJMBG(jmbg.Text) && prezime.Text.Length < 45 && IspravanIndeks(index.Text))
                    {
                        Uposlenik u = new Uposlenik(licna.Text, ime.Text, prezime.Text, adresa.Text, email.Text, telefon.Text, Convert.ToDateTime(datum.Text), jmbg.Text, tipUposlenika.Text);
                        u.Slika = (Bitmap)naslovnaStrana.Image;
                        dao.DodajUposlenika(u);


                        PrintPreviewDialog previewDialog = new PrintPreviewDialog();
                        PrintDocument      pd            = new PrintDocument();
                        pd.PrintPage += new PrintPageEventHandler(this.pd_Stampaj);

                        previewDialog.Document = pd;
                        previewDialog.SetBounds(50, -550, 200, 200);
                        previewDialog.ShowDialog();

                        toolStripStatusLabel1.Text = "";
                        ime.Text                    = prezime.Text = licna.Text = jmbg.Text = adresa.Text = email.Text = index.Text = telefon.Text = "";
                        faks.SelectedIndex          = 1;
                        clanarina.SelectedIndex     = 1;
                        tipUposlenika.SelectedIndex = 1;
                        naslovnaStrana.Image        = ((System.Drawing.Image)(Properties.Resources.Misc_User_icon));
                        //   ));
                        toolStripStatusLabel1.Text = "Korisnik dodan";
                    }
                    else
                    {
                        toolStripStatusLabel1.Text = "Unesite ispravne podatke, korisnik nije dodan!";
                    }
                }
                if (tabControl1.SelectedIndex == 1)
                {
                    if (ime.Text.Length < 1 || email.Text.Length < 1 || adresa.Text.Length < 1 || index.Text.Length < 1 || prezime.Text.Length < 1)
                    {
                        toolStripStatusLabel1.Text = "Popunite sva polja";
                    }
                    else if ((IspravnaLicna(licna.Text)) && ime.Text.Length < 45 && email.Text.Length < 50 && adresa.Text.Length < 45 && index.Text.Length < 11 && prezime.Text.Length < 45)
                    {
                        Student s = new Student(licna.Text, ime.Text, prezime.Text, adresa.Text, email.Text, telefon.Text, Convert.ToDateTime(datum.Text), Convert.ToInt16(index.Text), faks.Text, Convert.ToInt32(clanarina.Text));
                        s.Slika = (Bitmap)naslovnaStrana.Image;
                        dao.DodajStudenta(s);



                        if (tabControl1.SelectedIndex == 1)
                        {
                            student = true;
                        }

                        if (tabControl2.SelectedIndex == 5)
                        {
                            Image camera = Image.FromFile("capture.png");
                            slika = new Bitmap(camera);
                        }

                        PrintPreviewDialog previewDialog = new PrintPreviewDialog();
                        PrintDocument      pd            = new PrintDocument();
                        pd.PrintPage += new PrintPageEventHandler(this.pd_Stampaj);

                        previewDialog.Document = pd;
                        previewDialog.SetBounds(50, -550, 200, 200);
                        previewDialog.ShowDialog();

                        ime.Text                    = prezime.Text = licna.Text = jmbg.Text = adresa.Text = email.Text = index.Text = telefon.Text = "";
                        faks.SelectedIndex          = 1;
                        clanarina.SelectedIndex     = 1;
                        tipUposlenika.SelectedIndex = 1;
                        naslovnaStrana.Image        = ((System.Drawing.Image)(Properties.Resources.Misc_User_icon));
                        toolStripStatusLabel1.Text  = "Korisnik dodan";
                    }

                    else
                    {
                        toolStripStatusLabel1.Text = "Unesite ispravne podatke, korisnik nije dodan!";
                    }
                }
            }
            catch (Exception izuzetak)
            {
                MessageBox.Show(izuzetak.Message);
            }
        }