コード例 #1
0
        private void buttonAddSapXepTam_Click(object sender, EventArgs e)
        {
            ATINChamCongEntities context = new ATINChamCongEntities();

            if (checkBoxUpdateBySelectedEmployee.Checked)
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (row.Cells[0].Value == null)
                    {
                        continue;
                    }
                    if ((bool)row.Cells[0].Value == true)
                    {
                        context.spInsertSapxepLichTrinhTam(
                            dateEditFromDate.DateTime,
                            dateEditToDate.DateTime,
                            (string)comboBox2.SelectedValue,
                            (row.DataBoundItem as ViewSapXepLichTrinh).MaNguoi
                            );
                    }
                }
            }
            else
            {
                if (dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].DataBoundItem != null)
                {
                    context.spInsertSapxepLichTrinhTam(
                        dateEditFromDate.DateTime,
                        dateEditToDate.DateTime,
                        (string)comboBox2.SelectedValue,
                        (dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].DataBoundItem as ViewSapXepLichTrinh).MaNguoi
                        );
                }
            }
            var viewSapXepLichTrinh = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].DataBoundItem as ViewSapXepLichTrinh;

            DataGridView2Config(viewSapXepLichTrinh);
        }