Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try {
         asset.Id      = this._asset_id;
         asset.Remarks = int.Parse(this.metroComboBox1.SelectedValue.ToString());
         asset.DeleteAsset();
         MessageBox.Show("Asset Has Been Deleted");
         _employee_assets.EmployeeAssets();
         this.Close();
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var empId      = int.Parse(dataGridView1.CurrentRow.Cells["pkEmpId"].Value.ToString());
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                switch (this._employee_id > 0)
                {
                case true:
                    switch (this._asset_id > 0)
                    {
                    case true:
                        try {
                            asset.Id         = this._asset_id;
                            asset.EmployeeId = empId;
                            asset.TransferSelectedAsset();
                            _transfer_assets.EmployeeAssets();
                            MessageBox.Show("Asset Transfered");
                        }
                        catch (Exception ex) {
                            MessageBox.Show(ex.Message);
                        }

                        this.Close();
                        break;

                    case false:
                        DialogResult result = MessageBox.Show("Transfer All Assets?", "Confirmation", MessageBoxButtons.YesNo);
                        switch (result)
                        {
                        case DialogResult.Yes:
                            //Asset asset = new Asset();
                            try {
                                asset.EmployeeId = this._employee_id;
                                asset.TransferTo = empId;
                                asset.TransferAssets();
                                MessageBox.Show("Successfully Transfered");
                            }
                            catch (Exception ex) {
                                log = new Logs();
                                log.UserFriendlyError();
                            }

                            _transfer_assets._employeeId = empId;
                            _transfer_assets.EmployeeAssets();
                            this.Close();
                            //asset.
                            break;

                        default:
                            MessageBox.Show("No Changes Has been Made");
                            break;
                        }
                        break;
                    }

                    break;

                default:
                    _add_asset._employee_id        = empId;
                    _add_asset.txt_emp_id.Text     = dataGridView1.CurrentRow.Cells["Employee ID"].Value.ToString();
                    _add_asset.txt_name.Text       = dataGridView1.CurrentRow.Cells["Name"].Value.ToString();
                    _add_asset.txt_department.Text = dataGridView1.CurrentRow.Cells["Department"].Value.ToString();
                    _add_asset.txt_position.Text   = dataGridView1.CurrentRow.Cells["Position"].Value.ToString();
                    this.Close();
                    break;
                }
            }
        }