예제 #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     this.mode            = Mode.Null;
     this._addSub         = new popupClient();
     this._addSub.clientF = this;
     this._addSub.edit    = false;
     this._addSub.Show();
 }
예제 #2
0
        private void dgvClient_KeyDown(object sender, KeyEventArgs e)
        {
            Keys keyCode = e.KeyCode;

            if (keyCode == Keys.Return)
            {
                DataGridView dataGridView = (DataGridView)sender;
                int          index        = dataGridView.SelectedRows[0].Index;
                try
                {
                    if (this.mode == Mode.Edit)
                    {
                        this._addSub                    = new popupClient();
                        this._addSub.edit               = true;
                        this._addSub.clientF            = this;
                        this._addSub.row                = index;
                        this._addSub.tbAccCode.Text     = dataGridView.get_Item(6, index).Value.ToString();
                        this._addSub.tbEName.Text       = dataGridView.get_Item(1, index).Value.ToString();
                        this._addSub.tbNation.Text      = dataGridView.get_Item(3, index).Value.ToString();
                        this._addSub.tbPhone.Text       = dataGridView.get_Item(2, index).Value.ToString();
                        this._addSub.tbAddress.Text     = dataGridView.get_Item(5, index).Value.ToString();
                        this._addSub.tbID.Text          = dataGridView.get_Item(4, index).Value.ToString();
                        this._addSub.tbBalance.Visible  = false;
                        this._addSub.lblBalance.Visible = false;
                        this._addSub.Text               = "تعديل معلومات عميل";
                        this._addSub.Show();
                    }
                    else
                    {
                        if (this.mode != Mode.Delete || MessageBox.Show("متاكد من حذف العميل؟", "حذف", MessageBoxButtons.OKCancel) == 1)
                        {
                            int num = Convert.ToInt32(dataGridView.get_Item(6, index).Value);
                            this._client.deleteClient(num);
                            this.dgvClient.DataSource = this._client.getClient();
                            this.dgvClient.Refresh();
                        }
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(string.Concat(" لايمكن حذف العميل ", exception.Message));
                }
                goto L_021f;
            }
L_021f:
        }