Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ATINChamCongEntities context = new ATINChamCongEntities();

            if (checkBox2.Checked == false && checkBox1.Checked == false)
            {
                return;
            }
            if (checkBox1.Checked == true)
            {
                context.spInsertChamCongChiTiet(MaNhanVien, dateEdit1.DateTime, "IN", 3);
            }
            if (checkBox2.Checked == true)
            {
                context.spInsertChamCongChiTiet(MaNhanVien, dateEdit2.DateTime, "OUT", 3);
            }
            this.Close();
        }
Example #2
0
        // add time
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count < 1)
            {
                return;
            }
            if (timeEdit2.Enabled == false && timeEdit1.Enabled == false)
            {
                return;
            }
            Cursor.Current  = Cursors.WaitCursor;
            button2.Enabled = false;
            ATINChamCongEntities context = new ATINChamCongEntities();

            DateTime datetmp = DateTime.MinValue;

            try
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (row.Cells[0].Value == null)
                    {
                        continue;
                    }
                    if ((bool)row.Cells[0].Value == true)
                    {
                        // them gio vao nguon thuc hien = 3 => PC
                        if (timeEdit1.Enabled == true)
                        {
                            foreach (ListViewItem lvItem in listView1.Items)
                            {
                                if (lvItem.Checked == true)
                                {
                                    string s = (lvItem.Tag as int?).ToString() + "/" + (comboBox3.SelectedIndex + 1).ToString() + "/" + (2020 + comboBox2.SelectedIndex).ToString() + " " + timeEdit1.TimeSpan.ToString();
                                    datetmp = Convert.ToDateTime(s, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);
                                    context.spInsertChamCongChiTiet((row.DataBoundItem as Nguoi).MaNguoi, datetmp, "IN", 3);
                                }
                            }
                        }
                        // them gio ra
                        if (timeEdit2.Enabled == true)
                        {
                            foreach (ListViewItem lvItem in listView1.Items)
                            {
                                if (lvItem.Checked == true)
                                {
                                    string s = (lvItem.Tag as int?).ToString() + "/" + (comboBox3.SelectedIndex + 1).ToString() + "/" + (2020 + comboBox2.SelectedIndex).ToString() + " " + timeEdit2.TimeSpan.ToString();
                                    datetmp = Convert.ToDateTime(s, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);
                                    context.spInsertChamCongChiTiet((row.DataBoundItem as Nguoi).MaNguoi, datetmp, "OUT", 3);
                                }
                            }
                        }
                    }
                }
                MessageBox.Show("Thêm giờ chấm công thành công!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current  = Cursors.Default;
            button2.Enabled = true;
        }