Beispiel #1
0
        public Pendiente readOnePendiente(int idPendiente)
        {
            Pendiente pendiente = new Pendiente();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Pendiente_SelectRow", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdPendiente", idPendiente);

                con.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    // Loop through each record.
                    while (reader.Read())
                    {
                        Pendiente tmp = new Pendiente();

                        tmp.IdPendiente = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdPendiente;
                        tmp.IdFactura = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdFactura;
                        tmp.IdArticulo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(2)) : tmp.IdArticulo;
                        tmp.Cantidad = (reader.GetValue(3) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(3)) : tmp.Cantidad;

                        pendiente = tmp;
                    }
                }

                con.Close();
            }

            return pendiente;
        }
        public SinglePendiente(Pendiente reg)
        {
            InitializeComponent();
            pendiente = reg;
            this.DataContext = pendiente;

            btnActualizar.Visibility = Visibility.Visible;
            btnGuardar.Visibility = Visibility.Collapsed;
        }
Beispiel #3
0
        public string Create(Pendiente obj)
        {

            CreateDAC objDAC = new CreateDAC();
            if (objDAC.CreateRecord(obj) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Beispiel #4
0
 public string Update(Pendiente obj, int idPendiente)
        {

            UpdateDAC objDAC = new UpdateDAC();
            if (objDAC.UpdateRecord(obj, idPendiente) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Beispiel #5
0
        public bool CreateRecord(Pendiente obj)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_Pendiente_Insert", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@IdFactura", obj.IdFactura);
            cmd.Parameters.AddWithValue("@IdArticulo", obj.IdArticulo);
            cmd.Parameters.AddWithValue("@Cantidad", obj.Cantidad);
            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
            {
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;
            }
        }
Beispiel #6
0
        public List<Pendiente> readPendiente()
        {
            List<Pendiente> pendienteList = new List<Pendiente>();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Pendiente_SelectAll", con);
                cmd.CommandType = CommandType.StoredProcedure;

                con.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    // Loop through each record.
                    while (reader.Read())
                    {
                        Pendiente tmp = new Pendiente();

                        tmp.IdPendiente = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdPendiente;
                        tmp.IdFactura = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdFactura;
                        tmp.IdArticulo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(2)) : tmp.IdArticulo;
                        tmp.Cantidad = (reader.GetValue(3) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(3)) : tmp.Cantidad;

                        pendienteList.Add(tmp);
                    }
                }

                con.Close();
            }

            return pendienteList;
        }
        private void listEntrada_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (sender != null)
            {
                EntradaArticulo register = listEntradaArticulo.SelectedValue as EntradaArticulo;

                ReadOneBC objReadOne = new ReadOneBC();
                DeleteBC objDelete = new DeleteBC();
                CreateBC objCreate = new CreateBC();
                UpdateBC objUpdate = new UpdateBC();

                Articulo art = objReadOne.ReadOneArticulo(register.IdArticulo);
                art.Cantidad = art.Cantidad - register.Cantidad;
                objUpdate.Update(art, art.IdArticulo);

                Pendiente pend = new Pendiente();
                pend.IdArticulo = register.IdArticulo;
                pend.IdFactura = register.IdFactura;
                pend.Cantidad = register.Cantidad;
                objCreate.Create(pend);

                objDelete.DeleteEntrada(register.IdEntrada);

                Update();
            }
        }