Example #1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)    // F1
        {
            string para1 = "";
            string para2 = "";
            string para3 = "";

            if (keyData == Keys.F1 && tx_codm.Focused == true)
            {
                para1 = "items";
                para2 = "parcial";
                para3 = "";
                ayuda1 ayu1   = new ayuda1(para1, para2, para3);
                var    result = ayu1.ShowDialog();  //ayu1.Show();
                if (result == DialogResult.Cancel)  // deberia ser OK, pero que chuuu
                {
                    tx_codm.Text = ayu1.ReturnValue0;
                }
                return(true);    // indicate that you handled this keystroke
            }
            // Call the base class
            return(base.ProcessCmdKey(ref msg, keyData));
        }
Example #2
0
 private void tx_idped_Validating(object sender, CancelEventArgs e)
 {
     if (tx_idped.Text != "")
     {
         MySqlConnection cn = new MySqlConnection(DB_CONN_STR);
         cn.Open();
         try
         {
             string consulta = "select sum(b.saldo) as saldo from pedidos a " +
                               "left join detaped b on b.pedidoh=a.codped " +
                               "where a.tipoes='TPE001' and a.codped=@cp";
             MySqlCommand micon = new MySqlCommand(consulta, cn);
             micon.Parameters.AddWithValue("@cp", tx_idped.Text.Trim());
             MySqlDataReader dr = micon.ExecuteReader();
             if (dr.Read())
             {
                 if (dr.IsDBNull(0))
                 {
                     dr.Close();
                     cn.Close();
                     MessageBox.Show("No existe el código del pedido", "Atención - Verifique", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                     tx_idped.Text = "";
                     tx_idped.Focus();
                     return;
                 }
                 if (dr.GetInt16(0) == 0)
                 {
                     MessageBox.Show("El código de pedido ingresado NO tiene saldo", "Atención - Verifique", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                     dr.Close();
                     cn.Close();
                     tx_idped.Text = "";
                     tx_idped.Focus();
                     return;
                 }
                 if (dr.GetInt16(0) > 0)
                 {
                     dr.Close();
                     cn.Close();
                     ayuda1 ayu = new ayuda1("detaped", tx_idped.Text, "");
                     //ayu.Show();
                     if (ayu.ShowDialog() == DialogResult.Cancel && !string.IsNullOrEmpty(ayu.ReturnValue0))
                     {
                         //tx_codm.Text = ayu.ReturnValue0;
                         tx_dat_cap.Text  = ayu.ReturnValue0.Substring(0, 1);
                         tx_dat_mod.Text  = ayu.ReturnValue0.Substring(1, 3);
                         tx_dat_mad.Text  = ayu.ReturnValue0.Substring(4, 1);
                         tx_dat_tip.Text  = ayu.ReturnValue0.Substring(5, 2);
                         tx_dat_det1.Text = ayu.ReturnValue0.Substring(7, 2);
                         tx_dat_aca.Text  = ayu.ReturnValue0.Substring(9, 1);
                         tx_dat_tal.Text  = ayu.ReturnValue0.Substring(10, 2);
                         tx_dat_det2.Text = ayu.ReturnValue0.Substring(12, 3);
                         tx_dat_det3.Text = ayu.ReturnValue0.Substring(15, 3);
                         //tx_dat_jgo.Text = ayu.ReturnValue0.Substring(18, 4);
                         tx_nombre.Text  = ayu.ReturnValue2;
                         tx_medidas.Text = ayu.ReturnValue3;
                         tx_precio.Text  = ayu.ReturnValue4;
                         tx_itemPed.Text = ayu.ReturnValue0;
                         //
                         cmb_cap.SelectedIndex  = cmb_cap.FindString(tx_dat_cap.Text);
                         cmb_mod.SelectedIndex  = cmb_mod.FindString(tx_dat_mod.Text);
                         cmb_mad.SelectedIndex  = cmb_mad.FindString(tx_dat_mad.Text);
                         cmb_tip.SelectedIndex  = cmb_tip.FindString(tx_dat_tip.Text);
                         cmb_det1.SelectedIndex = cmb_det1.FindString(tx_dat_det1.Text);
                         cmb_aca.SelectedIndex  = cmb_aca.FindString(tx_dat_aca.Text);
                         cmb_tal.SelectedIndex  = cmb_tal.FindString(tx_dat_tal.Text);
                         cmb_det2.SelectedIndex = cmb_det2.FindString(tx_dat_det2.Text);
                         cmb_det3.SelectedIndex = cmb_det3.FindString(tx_dat_det3.Text);
                     }
                 }
             }
         }
         catch (MySqlException ex)
         {
             MessageBox.Show(ex.Message, "Error de conexión");
             Application.Exit();
             return;
         }
         cn.Close();
     }
 }