コード例 #1
0
 private void BtnActualizar_Click(object sender, EventArgs e)
 {
     try
     {
         ErrProvider.Clear();
         Cursor = Cursors.WaitCursor;
         if (Cboempresa1.SelectedIndex != -1 & ProductoID != "" & TxtNuevoPrecio.Text != "." & TxtNuevoPrecio.Text != "." & TxtNuevoPrecio.Text != "")
         {
             if (Convert.ToDecimal(TxtNuevoPrecio.Text) > 0)
             {
                 //obtener nuevo precio
                 E_ListaPrecio ObjE_ListaPrecio = new E_ListaPrecio();
                 ObjE_ListaPrecio.EmpresaID      = Cboempresa1.SelectedValue.ToString();
                 ObjE_ListaPrecio.SedeID         = AppSettings.SedeID;
                 ObjE_ListaPrecio.ProductoID     = ProductoID;
                 ObjE_ListaPrecio.PrecioUnitario = Convert.ToDecimal(TxtNuevoPrecio.Text);
                 ObjE_ListaPrecio.UsuarioID      = AppSettings.UserID;
                 ObjCL_Producto.UpdatePrecio(ObjE_ListaPrecio, AppSettings.SedeID);
                 MessageBox.Show("Se actualizo correctamente el precio", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LimpiarPrecio();
             }
             else
             {
                 ErrProvider.SetError(TxtNuevoPrecio, "precio debe ser diferente de cero.");
             }
         }
         else
         {
             if (Cboempresa1.SelectedIndex == -1)
             {
                 ErrProvider.SetError(Cboempresa1, "Seleccione una empresa.");
             }
             if (TxtNuevoPrecio.Text == "." | TxtNuevoPrecio.Text == "")
             {
                 ErrProvider.SetError(TxtNuevoPrecio, "Ingrese un precio valido");
             }
             else if (TxtNuevoPrecio.Text.Length > 0 && Convert.ToDecimal(TxtNuevoPrecio.Text) == 0)
             {
                 ErrProvider.SetError(TxtNuevoPrecio, "precio debe ser diferente de cero.");
             }
         }
         Cursor = Cursors.Default;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Cursor = Cursors.Default;
     }
 }