// 添加单据 private void materialRaisedButton1_Click(object sender, EventArgs e) { NewBill bill = new NewBill(this); bill.StartPosition = FormStartPosition.CenterParent; bill.ShowDialog(); }
private void BtnSearchDataCusto_Click(object sender, EventArgs e) { if (customer.FindCustomerBill(txtSearchDataCusto.Text).Count() == 1) { dataCustoBill.DataSource = customer.FindCustomerBill(txtSearchDataCusto.Text); //se localiza el formulario buscandolo entre los forms abiertos Form fnb = Application.OpenForms.Cast <Form>().FirstOrDefault(x => x is NewBill); if (fnb != null) { if (fnb.WindowState == FormWindowState.Minimized) { fnb.WindowState = FormWindowState.Normal; } //si la instancia existe la pongo en primer plano fnb.BringToFront(); return; } //sino existe la instancia se crea una nueva NewBill NB = new NewBill(); NB.Show(); NB.txtIdCustoBill.Text = dataCustoBill.CurrentRow.Cells[0].Value.ToString(); NB.txtNameCustoBill.Text = dataCustoBill.CurrentRow.Cells[1].Value.ToString(); NB.txtPhoneCustoBill.Text = dataCustoBill.CurrentRow.Cells[4].Value.ToString(); NB.txtDateCustoBill.Text = DateTime.Now.ToString(); NB.txtAddressCustoBill.Text = dataCustoBill.CurrentRow.Cells[3].Value.ToString(); NB.txtRucCustoBill.Text = dataCustoBill.CurrentRow.Cells[2].Value.ToString(); //NB.TxtPrecioBill.Text = "Por Mayor"; Close(); NB.Show(); //NC.FormClosed += new FormClosedEventHandler(NewCustomers_FormClosed); } else { int b = customer.FindCustomerBill(txtSearchDataCusto.Text).Count(); MessageBox.Show("Cantidad de archivos encontrados:" + b); } }