Beispiel #1
0
        private void dgvBusType_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            try
            {
                switch (e.ColumnIndex)
                {
                case 0:
                    this.recordID = this.dgvBusType.Rows[e.RowIndex].Cells["BusTypeID"].Value.ToString();

                    this.txtBusTypeCode.Text = this.dgvBusType.Rows[e.RowIndex].Cells["BusTypeCode"].Value.ToString();
                    this.txtDescription.Text = this.dgvBusType.Rows[e.RowIndex].Cells["Description"].Value.ToString();
                    this.txtTotalSeats.Text  = this.dgvBusType.Rows[e.RowIndex].Cells["TotalSeats"].Value.ToString();

                    this.btnSave.Text = "&Update";
                    break;

                case 1:
                    if (Globalizer.ShowMessage(MessageType.Question, "Are you sure want to delete?") == DialogResult.Yes)
                    {
                        recordID = this.dgvBusType.Rows[e.RowIndex].Cells["BusTypeID"].Value.ToString();
                        BusTypeController busTypeController = new BusTypeController();

                        busTypeController.DeleteByBusTypeID(recordID);

                        string log = "Form-BusType;Item-BusCode:" + this.txtBusTypeCode.Text + ";action-Delete";
                        userAction.Log(log);

                        this.InitializeControls();
                        this.BindDataGridView();
                        Globalizer.ShowMessage(MessageType.Information, "Deleted Successfully");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Globalizer.ShowMessage(MessageType.Critical, ex.Message);
            }
        }