예제 #1
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // My combobox column is the second one so I hard coded a 1, flavor to taste
            DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[5];

            if (cb.Value != null)
            {
                var comboId = cb.Value.ToString();
                var row_id  = dataGridView1.Rows[e.RowIndex].Cells["id"].Value.ToString();

                if (comboId == "Update")
                {
                    MessageBox.Show("Only admin can make changes");
                }
                else if (comboId == "Delete")
                {
                    MessageBox.Show("Only admin can make changes");
                }
                else if (comboId == "Account Statement")
                {
                    this.Hide();
                    ReportForms.allotteeStatement repForm = new ReportForms.allotteeStatement(Int32.Parse(row_id));
                    repForm.Show();
                    this.Close();
                }
                else if (comboId == "Add Payment")
                {
                    MessageBox.Show("Only admin can make changes");
                }
                else if (comboId == "Documents")
                {
                    this.Hide();
                    //  int id = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[5].Value.ToString());
                    Allottees.scannedDocs cc = new Allottees.scannedDocs(Int32.Parse(row_id));
                    cc.Show();
                    this.Close();
                }
                // do stuff
            }
        }
예제 #2
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // My combobox column is the second one so I hard coded a 1, flavor to taste
            DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[5];

            if (cb.Value != null)
            {
                var comboId = cb.Value.ToString();
                var row_id  = dataGridView1.Rows[e.RowIndex].Cells["id"].Value.ToString();

                if (comboId == "Update")
                {
                    var p = new Props();
                    p.id = Int32.Parse(row_id);
                    Allottees.editAllottees edit = new Allottees.editAllottees(p.id);
                    edit.Show();
                }
                else if (comboId == "Delete")
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure you want to Delete", "Delete", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        try
                        {
                            //con.dataSend("DELETE FROM allottees WHERE(id = 8)");

                            //db = new giedaEntities1();
                            //var allotte = db.allottees.Where(x => x.id == Int32.Parse(row_id)).FirstOrDefault();
                            //if (allotte != null)
                            //{
                            //    db.allottees.Remove(allotte);
                            //    db.SaveChanges();
                            //}
                            //db.allottees.Attach(allotte);
                            //db.allottees.Remove(allotte);
                            //db.SaveChanges();

                            con.Delete("Delete From [allottees] where id=" + Int32.Parse(row_id) + "");



                            loadData();

                            MessageBox.Show("Deleted Successfully", "Message", MessageBoxButtons.OK);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                else if (comboId == "Account Statement")
                {
                    this.Hide();
                    ReportForms.allotteeStatement repForm = new ReportForms.allotteeStatement(Int32.Parse(row_id));
                    repForm.Show();
                    this.Close();
                }
                else if (comboId == "Add Payment")
                {
                    this.Hide();
                    //  int id = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[5].Value.ToString());
                    Allottees.allotteesPayment cc = new Allottees.allotteesPayment(Int32.Parse(row_id));
                    cc.Show();
                    this.Close();
                }
                else if (comboId == "Documents")
                {
                    this.Hide();
                    //  int id = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[5].Value.ToString());
                    Allottees.scannedDocs cc = new Allottees.scannedDocs(Int32.Parse(row_id));
                    cc.Show();
                    this.Close();
                }
                // do stuff
            }
        }