Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int  p1     = Convert.ToInt32(tb_1h.Text.Trim());
            int  p2     = Convert.ToInt32(tb_3h.Text.Trim());
            int  p3     = Convert.ToInt32(tb_b3h.Text.Trim());
            int  punish = 0;
            int  cb     = Convert.ToInt32(tb_cb.Text.Trim());
            bool flag   = new AttendanceBAL().Insert6(p1, p2, p3, cb);

            if (flag)
            {
                MessageBox.Show("设置成功!");
            }
        }
Beispiel #2
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            DateTime d1 = dp_smw.Value;
            DateTime d2 = dp_sme.Value;
            DateTime d3 = dp_saw.Value;
            DateTime d4 = dp_sae.Value;
            // string season = cb_sea.Text.Trim();
            bool flag = new AttendanceBAL().Insert5(d1, d2, d3, d4);

            if (flag)
            {
                MessageBox.Show("设置成功!");
            }
        }
Beispiel #3
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            string strcolumn = dataGridView1.Columns[e.ColumnIndex].DataPropertyName;//获取列datapropertyname

            if (e.RowIndex.ToString() != "-1")
            {
                if (Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[0].Value) == false)
                {
                    int      strrow = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()); //获取焦点触发行的第二个值
                    string   d      = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();                  //获取焦点触发行的日期
                    DateTime date   = DateTime.Parse(d);
                    string   value  = dataGridView1.CurrentCell.Value.ToString();
                    bool     flag   = new AttendanceBAL().Update5(strcolumn, value, strrow, date);
                    cc++;
                }
            }
        }
Beispiel #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            DateTime t1   = dp_s1.Value.Date;
            DateTime t2   = dp_s2.Value.Date;
            string   name = tb_name.Text.Trim();

            if (name == "")
            {
                DataTable dt = new AttendanceBAL().Select10(t1, t2);
                dataGridView1.DataSource = dt;
            }
            else
            {
                DataTable dt = new AttendanceBAL().Select11(t1, t2, name);
                dataGridView1.DataSource = dt;
            }
        }
Beispiel #5
0
        private void button4_Click(object sender, EventArgs e)
        {
            int[] a = new int[10000];
            for (int i = 0; i < 9999; i++)
            {
                a[i] = 0;
            }
            int          j      = 0;
            bool         flag1  = false;
            DialogResult button = MessageBox.Show("确定要删除本条信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

            if (button == DialogResult.Yes)
            {
                flag1 = true;
            }
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value) == true)
                {
                    a[j++] = i;
                    //   dataGridView1.Rows.Remove(dataGridView1.Rows[i]);
                    int      strrow = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value.ToString()); //获取焦点触发行的第二个值
                    string   d      = dataGridView1.Rows[i].Cells[3].Value.ToString();                  //获取焦点触发行的日期
                    DateTime date   = DateTime.Parse(d);
                    bool     flag   = new AttendanceBAL().Delete(strrow, date);
                }
            }
            int s = 0;

            if (flag1 == true)
            {
                while (a[s] >= 0)
                {
                    dataGridView1.Rows.RemoveAt(a[s]);
                    for (int i = s + 1; i < 9999; i++)
                    {
                        a[i] = a[i] - 1;
                    }
                    s++;
                }
            }
        }
Beispiel #6
0
        private void  班打卡ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.DateTime currentTime = System.DateTime.Now;
            int             hour        = currentTime.Hour;//取当前时
            int             minute      = currentTime.Minute;
            int             month       = currentTime.Month;
            string          strYMD      = currentTime.ToString("d");//取当前年月日,格式为:2003-9-23
            DateTime        date        = DateTime.Parse(strYMD);
            DataTable       dtt         = new AttendanceBAL().Select7();

            // DateTime date = DateTime.ParseExact(strYMD, "yyyy/MM/dd", CultureInfo.InvariantCulture);
            // string strT = currentTime.ToString("t");//取当前时分,格式为:14:24
            if (hour >= 0 && hour <= 12)
            {
                DataTable d = new AttendanceBAL().Select5(UId, date, strYMD);
                if (d.Rows.Count == 0)
                {
                    DataTable dt = new AttendanceBAL().Select(UId, date);
                    if (dt.Rows.Count == 0)
                    {
                        bool flag = new AttendanceBAL().Insert2(UId, UserName, date, currentTime);
                        if (flag == true)
                        {
                            MessageBox.Show("打卡成功!");
                        }
                    }
                    else
                    {
                        bool flag = new AttendanceBAL().Update("morningend", currentTime, UId, date);
                        if (flag == true)
                        {
                            MessageBox.Show("打卡成功!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("已打卡!");
                }

                DateTime t2 = DateTime.Parse(dtt.Rows[0][1].ToString());
                int      h2 = t2.Hour;//取应打卡的时
                int      m2 = t2.Minute;

                ih2 = h2 - hour;
                if (ih2 < 0)
                {
                    ih2 = 0;
                    im2 = 0;
                }
                else
                {
                    im2 = m2 - minute;
                    if (im2 < 0)
                    {
                        im2 = 60 + im2;
                        ih2--;
                    }
                }
            }
            else
            {
                DataTable d = new AttendanceBAL().Select6(UId, date, strYMD);

                if (d.Rows.Count == 0)
                {
                    DataTable dt = new AttendanceBAL().Select(UId, date);
                    if (dt.Rows.Count == 0)
                    {
                        bool flag = new AttendanceBAL().Insert4(UId, UserName, date, currentTime);
                        if (flag == true)
                        {
                            MessageBox.Show("打卡成功!");
                        }
                    }
                    else
                    {
                        bool flag = new AttendanceBAL().Update("afternoonend", currentTime, UId, date);
                        if (flag == true)
                        {
                            MessageBox.Show("打卡成功!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("已打卡!");
                }

                DateTime t4 = DateTime.Parse(dtt.Rows[0][3].ToString());
                int      h4 = t4.Hour;//取应打卡的时
                int      m4 = t4.Minute;

                ih4 = h4 - hour;
                if (ih4 < 0)
                {
                    ih4 = 0;
                    im4 = 0;
                }
                else
                {
                    im4 = m4 - minute;
                    if (im4 < 0)
                    {
                        im4 = 60 + im4;
                        ih4--;
                    }
                }

                DataTable dt2     = new AttendanceBAL().Select8(date);//查当前的记录
                int       id      = Convert.ToInt32(dt2.Rows[0][0].ToString());
                string    dc      = "";
                string    allwork = "";
                DataTable dt11    = new AttendanceBAL().Select9();//查最新的扣罚金额设置记录
                int       p1      = Convert.ToInt32(dt11.Rows[0][0].ToString());
                int       p2      = Convert.ToInt32(dt11.Rows[0][1].ToString());
                int       p3      = Convert.ToInt32(dt11.Rows[0][2].ToString());
                int       cb      = Convert.ToInt32(dt11.Rows[0][3].ToString());
                int       punish  = 0;
                if (dt2.Rows[0][3].ToString() != "" && dt2.Rows[0][4].ToString() != "" && dt2.Rows[0][5].ToString() != "" && dt2.Rows[0][6].ToString() != "")
                {
                    allwork = "否";
                    int zh = ih1 + ih2 + ih3 + ih4; //相差的总时
                    int zm = im1 + im2 + im3 + im4; //相差的总分
                    sum = zh * 60 + zm;             //全分
                    if (sum > 0 && sum <= 10)
                    {
                        dc = "1";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 10 && sum <= 20)
                    {
                        dc = "2";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 2;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 20 && sum <= 30)
                    {
                        dc = "3";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 3;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 30 && sum <= 40)
                    {
                        dc = "4";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 4;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 40 && sum <= 50)
                    {
                        dc = "5";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 5;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 50 && sum <= 60)
                    {
                        dc = "6";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 6;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 60 && sum <= 90)
                    {
                        dc = "7";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 6 + p2;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 90 && sum <= 120)
                    {
                        dc = "8";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 6 + p2 * 2;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 120 && sum <= 150)
                    {
                        dc = "9";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 6 + p2 * 3;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 150 && sum <= 180)
                    {
                        dc = "10";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p1 * 6 + p2 * 4;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else if (sum > 180)
                    {
                        dc = "11";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = p3;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                    else
                    {
                        dc = "0";
                        bool flag = new AttendanceBAL().Update3(dc, id, UId);
                        punish = 0;
                        bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                    }
                }
                else
                {
                    dc = "11";
                    bool flag = new AttendanceBAL().Update3(dc, id, UId);
                    allwork = "是";
                    punish  = p3;
                    bool flg = new AttendanceBAL().Update4(cb, punish, allwork, UId, date);
                }
            }
        }
Beispiel #7
0
        int im4 = 0; //下午下班打卡分钟差

        private void  班打卡ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.DateTime currentTime = System.DateTime.Now;
            DataTable       dtt         = new AttendanceBAL().Select7();
            int             hour        = currentTime.Hour;          //取当前时
            int             minute      = currentTime.Minute;
            string          strYMD      = currentTime.ToString("d"); //取当前年月日,格式为:2003-9-23
            DateTime        date        = DateTime.Parse(strYMD);
            int             month       = currentTime.Month;

            if (hour >= 0 && hour <= 12)
            {
                DataTable d = new AttendanceBAL().Select3(UId, date, strYMD);
                if (d.Rows.Count == 0)
                {
                    bool flag = new AttendanceBAL().Insert(UId, UserName, date, currentTime);
                    if (flag == true)
                    {
                        MessageBox.Show("打卡成功!");
                    }
                }
                else
                {
                    MessageBox.Show("已打卡!");
                }


                DateTime t1 = DateTime.Parse(dtt.Rows[0][0].ToString());
                // DateTime t2 = DateTime.Parse(dt.Rows[0][2].ToString());
                // DateTime t3 = DateTime.Parse(dt.Rows[0][3].ToString());
                //  DateTime t4 = DateTime.Parse(dt.Rows[0][4].ToString());
                int h1 = t1.Hour;   //取应打卡的时
                int m1 = t1.Minute; //取应打卡分

                ih1 = hour - h1;
                if (ih1 < 0)
                {
                    ih1 = 0;
                    im1 = 0;
                }
                else
                {
                    im1 = minute - m1;
                    if (im1 < 0)
                    {
                        im1 = 60 + im1;
                        ih1--;
                    }
                }
            }
            else
            {
                DataTable d = new AttendanceBAL().Select4(UId, date, strYMD);
                if (d.Rows.Count == 0)
                {
                    DataTable dt = new AttendanceBAL().Select(UId, date);
                    if (dt.Rows.Count == 0)
                    {
                        bool flag = new AttendanceBAL().Insert3(UId, UserName, date, currentTime);
                        if (flag == true)
                        {
                            MessageBox.Show("打卡成功!");
                        }
                    }
                    else
                    {
                        bool flag = new AttendanceBAL().Update("afternoonwork", currentTime, UId, date);
                        if (flag == true)
                        {
                            MessageBox.Show("打卡成功!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("已打卡!");
                }

                DateTime t3 = DateTime.Parse(dtt.Rows[0][2].ToString());
                int      h3 = t3.Hour;//取应打卡的时
                int      m3 = t3.Minute;

                ih3 = hour - h3;
                if (ih3 < 0)
                {
                    ih3 = 0;
                    im3 = 0;
                }
                else
                {
                    im3 = minute - m3;
                    if (im3 < 0)
                    {
                        im3 = 60 + im3;
                        ih3--;
                    }
                }
            }
        }