private void GetRegisterData() { if (this.dgvRegister.Rows[this.dgvRegister.CurrentCell.RowIndex].Tag is RegisterData) { this.rg = (RegisterData)this.dgvRegister.Rows[this.dgvRegister.CurrentCell.RowIndex].Tag; bool get_serial_success = false; this.FormBegining(); this.FormProcessing(); RegisterData reg = (RegisterData)this.dgvRegister.Rows[this.dgvRegister.CurrentCell.RowIndex].Tag; this.wAddr01.Text = reg.comp_addr1; this.wAddr02.Text = reg.comp_addr2; this.wAddr03.Text = reg.comp_addr3; this.wBusides.Text = reg.comp_bus_desc; this.wBusityp.Text = reg.comp_bus_type; this.wCompnam.Text = reg.comp_name; this.wContact.Text = reg.cont_name; this.wContEmail.Text = reg.cont_email; this.wContTelnum.Text = reg.cont_tel; this.dealer_code = (reg.purchase_from == "Express" ? "X-ESG" : ""); this.wDealer.Text = (reg.purchase_from == "Express" ? reg.purchase_from : reg.purchase_from_desc); this.wEmail.Text = reg.comp_email; this.wFaxnum.Text = reg.comp_fax; this.wPosition.Text = reg.cont_position; this.wPrenam.Text = reg.comp_prenam; this.wSernum.Text = reg.sn; this.wTelnum.Text = reg.comp_tel; this.wZipcod.Text = reg.comp_zipcod; this.wRegDate.pickedDate(reg.reg_date); this.sRegDate.pickedDate(reg.reg_date); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "serial/get_sn_register&sernum=" + this.wSernum.Text); ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { if (sr.serial.Count > 0) { this.serial = sr.serial[0]; get_serial_success = true; } else { this.serial = null; get_serial_success = false; MessageAlert.Show("Can not find this S/N", "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } if (sr.problem.Count > 0) { this.prob_email = sr.problem[0].probdesc; } else { this.prob_email = ""; } } else { this.serial = null; get_serial_success = false; MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } }; worker.RunWorkerCompleted += delegate { if (get_serial_success) { this.sAddr01.Text = this.serial.addr01; this.sAddr02.Text = this.serial.addr02; this.sAddr03.Text = this.serial.addr03; this.sBusides.Text = this.serial.busides; this.sBusityp.Text = this.serial.busityp; this.lblBusityp_typdes.Text = (this.parent_window.main_form.data_resource.LIST_BUSITYP.Find(t => t.typcod == this.sBusityp.Text) != null ? this.parent_window.main_form.data_resource.LIST_BUSITYP.Find(t => t.typcod == this.sBusityp.Text).typdes_th : ""); this.sCompnam.Text = this.serial.compnam; this.sContact.Text = this.serial.contact; this.sContEmail.Text = ""; this.sContTelnum.Text = ""; //this.sDealer.Text = this.dealer_code; this.sDealer.Text = this.serial.dealer_dealer; this.lblDealer_Compnam.Text = (this.parent_window.main_form.data_resource.LIST_DEALER.Find(t => t.dealer == this.sDealer.Text) != null ? this.parent_window.main_form.data_resource.LIST_DEALER.Find(t => t.dealer == this.sDealer.Text).compnam : ""); this.sEmail.Text = this.prob_email; this.sFaxnum.Text = this.serial.faxnum; this.sPosition.Text = this.serial.position; this.sPrenam.Text = this.serial.prenam; this.sSernum.Text = this.serial.sernum; this.sTelnum.Text = this.serial.telnum; this.sZipcod.Text = this.serial.zipcod; this.FormEditing(); this.sPrenam.Focus(); } else { this.FormBegining(); } }; worker.RunWorkerAsync(); } }
private void btnCancel_Click(object sender, EventArgs e) { this.serial = null; this.rg = null; this.dealer_code = ""; this.prob_email = ""; this.FormBegining(); }