Пример #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();

            if (value == "Edit")
            {
                btn_Add.Enabled = false;
                string id1 = dataGridView1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                id = Convert.ToInt32(id1);
                txt_CloName.Text   = dataGridView1.Rows[e.RowIndex].Cells[1].FormattedValue.ToString();
                dateCreated        = dataGridView1.Rows[e.RowIndex].Cells[2].FormattedValue.ToString();
                btn_Add.Enabled    = false;
                btn_Update.Enabled = true;
            }
            else if (value == "Delete")
            {
                string id1 = dataGridView1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                id = Convert.ToInt32(id1);

                AddClo c = new AddClo();
                c.Delete(id);
                //c.ShowInGrid();
                DataTable dt = c.ShowInGrid();
                dataGridView1.DataSource = dt;
                btn_Update.Enabled       = false;
            }
        }
Пример #2
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            AddClo c = new AddClo();

            c.name        = txt_CloName.Text;
            c.dateCreated = DateTime.Now;
            c.dateUpdated = DateTime.Now;

            lbl_ErrorName.Text      = c.ErrorName(c.name);
            lbl_ErrorName.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorName.Refresh();
            if (string.IsNullOrEmpty(txt_CloName.Text))
            {
                lbl_ErrorName.Text      = "Invalid Clo Name";
                lbl_ErrorName.ForeColor = System.Drawing.Color.Red;
                lbl_ErrorName.Refresh();
            }
            else if (lbl_ErrorName.Text == "")
            {
                if (c.CloAlreadyExist(txt_CloName.Text))
                {
                    MessageBox.Show("CLO Aready Exists");
                }
                else
                {
                    c.add();
                    txt_CloName.Clear();
                    DataTable dt = c.ShowInGrid();
                    dataGridView1.DataSource = dt;
                }
            }
        }
Пример #3
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            AddClo c = new AddClo();

            c.name        = txt_CloName.Text;
            c.dateUpdated = DateTime.Now;
            DataTable dt = c.Edit(id);

            dataGridView1.DataSource = dt;
            txt_CloName.Clear();
            btn_Add.Enabled    = true;
            btn_Update.Enabled = false;
        }
Пример #4
0
        private void Clo_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'projectBDataSet1.Clo' table. You can move, or remove it, as needed.
            this.cloTableAdapter.Fill(this.projectBDataSet1.Clo);

            lbl_ErrorName.Text = "";

            btn_AddClo.Enabled   = false;
            btn_AddClo.BackColor = Color.Gray;

            AddClo    c  = new AddClo();
            DataTable dt = c.ShowInGrid();

            dataGridView1.DataSource = dt;

            btn_Update.Enabled = false;
            btn_Add.Enabled    = true;
        }