Beispiel #1
0
        private void aBRIALMACENToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Se Busca el formulario, buscandolo entre los forms abiertos
            Form FrmEvitarMultipleForm = Application.OpenForms.Cast <Form>().FirstOrDefault(x => x is FrmAbirAlmacen);

            if (FrmEvitarMultipleForm != null)
            {
                //si la instancia existe la pongo en primer plano
                FrmEvitarMultipleForm.BringToFront();
                return;
            }
            //--------------------------------------------

            //Abrir Formulario dentro del MDI.
            FrmAbirAlmacen abrir = new FrmAbirAlmacen();

            abrir.MdiParent = this;
            abrir.Show();
            //--------------------------------------------
        }
Beispiel #2
0
        private void aBRIRALMACENToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlDataReader lector = fn.selectMultiValues("select top(1)aa.IDApertura,cast(c.FECHA_HORA as date) as Fecha,aa.Estado from AperturaAlmacen aa inner join CAJA c on aa.IDCaja = c.ID order by IDApertura desc");
                lector.Read();

                string IDApertura = lector["IDApertura"].ToString();
                string Fecha      = lector["Fecha"].ToString();
                string Estado     = lector["Estado"].ToString();

                //VERIFICAMOS SI EL ALMACEN SE ENCUENTRA CERRADO
                if (Estado == "A")
                {
                    MessageBox.Show("El Almacen se Encuentra Abierto desde el Dia " + Fecha, "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                string idCaja = fn.select_one_value("MAX(ID)", "Caja", "ID>0", 0);


                DateTime fecha = DateTime.Now.Date;

                string ultimaFechaCaja = fn.select_one_value("top(1)cast(FECHA_HORA as Date)", "Caja", "ID>=0 order by ID Desc", 0);

                if (fecha != Convert.ToDateTime(ultimaFechaCaja))
                {
                    DialogResult msj = MessageBox.Show("Seguro que Desea Abrir Almacen con la Caja del Dia " + Convert.ToDateTime(ultimaFechaCaja).ToShortDateString() + " Estando Hoy con Diferente Fecha: " + fecha.ToShortDateString(), "Taberna", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                    if (msj == DialogResult.Cancel)
                    {
                        return;
                    }
                }


                if (fn.Existencia("*", "CAja", "ID>0") == true)
                {
                    if (fn.select_one_value("top(1)ESTADO", "CAJA", "ID>=0  ORDER BY ID DESC", 0) == "CERRADA")
                    {
                        MessageBox.Show("PRIMERO ABRIR CAJA", "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (fn.Existencia("*", "AperturaAlmacen", "IDCaja='" + idCaja + "'") == true)
                    {
                        MessageBox.Show("ALMACEN YA SE ENCUENTRA ABIERTO", "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        //Se Busca el formulario, buscandolo entre los forms abiertos
                        Form FrmEvitarMultipleForm = Application.OpenForms.Cast <Form>().FirstOrDefault(x => x is FrmAbirAlmacen);

                        if (FrmEvitarMultipleForm != null)
                        {
                            //si la instancia existe la pongo en primer plano
                            FrmEvitarMultipleForm.BringToFront();
                            return;
                        }
                        //--------------------------------------------

                        //Abrir Formulario dentro del MDI.
                        FrmAbirAlmacen abrir = new FrmAbirAlmacen();
                        abrir.MdiParent = this;
                        abrir.Show();
                        //--------------------------------------------
                    }
                }
                else
                {
                    MessageBox.Show("ABRIR CAJA", "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Factu-TED", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }