Exemplo n.º 1
0
        private void dgvCusKeys_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            var cusSelected = (MCustomer)dgvCustomerList.CurrentRow.DataBoundItem;

            CreateKeyForm createKeyForm = new CreateKeyForm();

            createKeyForm.Mode            = CreateKeyForm.ViewMode.EDIT;
            createKeyForm.currentCustomer = cusSelected;
            CustomerKey   cusKey    = null;
            List <string> lstOldMac = new List <string>();

            try
            {
                var x = SQLiteCommon.GetALlKeyDevices();

                cusKey = (CustomerKey)dgvCusKeys.CurrentRow.DataBoundItem;
                if (cusKey == null)
                {
                    return;
                }

                lstOldMac = SQLiteCommon.GetCustomerKeyByKeyCode(cusKey.KeyCode).ListMacAddress;
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ShowMsg(MessageBoxIcon.Error, ex.Message);
            }

            Params param = new Params
            {
                KeyCode     = cusKey.KeyCode,
                MachineCode = cusKey.MachineCode,
                ListMacs    = lstOldMac
            };

            createKeyForm.param = param;
            createKeyForm.InitForm();
            DialogResult result = createKeyForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (createKeyForm.isSuccess)
                {
                    loadCustomerKey();
                }
            }
        }
Exemplo n.º 2
0
        private void btnAddKey_Click(object sender, EventArgs e)
        {
            if (dgvCustomerList.CurrentRow != null)
            {
                var cusSelected = (MCustomer)dgvCustomerList.CurrentRow.DataBoundItem;

                CreateKeyForm createKeyForm = new CreateKeyForm();
                createKeyForm.currentCustomer = cusSelected;
                DialogResult result = createKeyForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (createKeyForm.isSuccess)
                    {
                        loadCustomerKey();
                    }
                }
            }
            else
            {
                ShowMsg(MessageBoxIcon.Warning, "Please select a customer!");
            }
        }